IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java Discussion :

Besoin d'aide java.lang.NullPointerException


Sujet :

Java

  1. #1
    Membre très actif
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    146
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 146
    Par défaut Besoin d'aide java.lang.NullPointerException
    bonjour je bute sur une exception causée par un this à cet endroit de mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
      private void mnuDossierEnregSous_Click()
      {
        try
        {
          VbFont x = new VbFont();
          // On Error Resume Next (optionally ignored)
          if( Variable.DejaFaitUnCalc == true )
          {
            x.setName( "Monospaced" );
            x.setSize( 11 );
            Pend.getFrmImprimer();
            Variable.Enregistrer = true;
            Variable.Enregistrer1 = true;
            Impression.ImprDossierPend();
            //À faire : Définir les indicateurs et les attributs du contrôle des dialogues communs
            Cmd.setFilter( "Documents (*.25000.doc)|*.25000.doc" );
            Cmd.setDialogTitle( "Enregistrer sous du Dossier en .doc" );
            Variable.sFile1 = Strings.replace( Variable.sFile1, ".25000.doc", "" );
            Variable.sFile1 = Strings.replace( Variable.sFile1, ".25000.dao", "" );
            Cmd.setFileName( Variable.sFile1 );
            //unsup Cmd.CancelError = true;
            Cmd.setInitDir( System.getProperty("user.dir") + "\\Resultats" );
            Cmd.showSave();
            Variable.sFile1 = Cmd.getFileName();
            Variable.sFile2 = Variable.sFile1;
            if( Err.getError().getNumber() != new Variant( this ).getValue( "MSComDlg.cdlCancel" ).toInt() )
            {
              Pend.getFrmImprimer().RichTxtImpr.saveFile( Variable.sFile1 );
            }
            else
            {
              Variable.Enregistrer = false;
              Variable.Enregistrer1 = false;
            }
    Pour info je dois porter une application VB6 en Java j'ai utilisé un outil appelé VB Converter

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    "this" n'est jamais null et n'est pas la cause de ton erreur. Si ton nullpointerexception pointe bien sur les lignes mentionnées en gras dans ton code, tu as les possibilités suivantes:

    • Err est null
    • Err.getError() renvoie null
    • new Variant( this ).getValue( "MSComDlg.cdlCancel" ) renvoie null
    • Pend est null
    • Pend.getFrmImprimer() renvoie null
    • Pend.getFrmImprimer().RichTxtImpr est null


    Tu dois tester toutes ces valeurs pour voir laquelle est en cause.

  3. #3
    Membre très actif
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    146
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 146
    Par défaut
    Je viens de tester mon code en débug sous Eclipse.

    J'ai trouvé que new Variant( this ).getValue( "MSComDlg.cdlCancel" ) renvoie null

    En fait cette méthode permet de sauvegarder dans un fichier Word le résultat d'un traitement.

  4. #4
    Membre très actif
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    146
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 146
    Par défaut
    J'ai remplacé :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
            if( Err.getError().getNumber() != new Variant( this ).getValue( "MSComDlg.cdlCancel" ).toInt() )
            {
              Pend.getFrmImprimer().RichTxtImpr.saveFile( Variable.sFile1 );
            }
    par :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
            if( Err.getError().getNumber() != 0 )
            {
              Pend.getFrmImprimer().RichTxtImpr.saveFile( Variable.sFile1 );
            }
    Et là j'ai plus l'exception mais par contre mon fichier est sauvegardé avec un nom défini par défaut dans mon code. Je me demande si le problème ne vient pas de la librairie MSComDlg.ocx puisque je le répète je porte du code VB6 en Java. A la base le code VB6 était le suivant :


  5. #5
    Membre très actif
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    146
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 146
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
     
    '#####################################################################################
    'Sur click de Dossier->enregistrer
    Private Sub mnuDossierEnreg_Click()
    Dim a As Integer
    Dim x As New StdFont
        If DejaFaitUnCalc = True Then 'On peut enregistrer seulement si on a deja fait un calcul
            x.Name = "Courier New"
            x.Size = 10
            Set FrmImprimer.RichTxtImpr.Font = x
            If Enregistrer = True Then
                ImprDossierPend
                a = MsgBox("Voulez vous ecraser l'ancien fichier?", vbOKCancel)
                If a = vbOK Then
                    If Err <> MSComDlg.cdlCancel Then
                        FrmImprimer.RichTxtImpr.SaveFile sFile1
                    Else
                        Enregistrer1 = False
                    End If
                    If Enregistrer1 = True Then
                        ImprDAOPend
                        If Err <> MSComDlg.cdlCancel Then
                            FrmImprimer.RichTxtImpr.SaveFile sFile2
                        Else
                            Enregistrer1 = False
                        End If
                    If OkQuit = True And Err <> MSComDlg.cdlCancel Then
                        Unload Me
                    End If
                    End If
                Else
                    mnuDossierEnregSous_Click
                End If
            Else
                mnuDossierEnregSous_Click
            End If
        Else
            MsgBox "Vous devez effectuer au moins un calcul pour pouvoir enregistrer"
        End If
    End Sub

  6. #6
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    je ne connais ni tes ocx, ni le vb, et le support pour l'appel d'ocx en java passe par des librairies natives non standard, donc le comportement m'est tout aussi inconnu.

  7. #7
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    372
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 372
    Par défaut
    Citation Envoyé par youness78 Voir le message
    mon fichier est sauvegardé avec un nom défini par défaut dans mon code
    C'est à dire, lequel ?

    D'autre part, en lisant le code que tu as donné, il me semble que ton
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Err.getError().getNumber() != new Variant( this ).getValue( "MSComDlg.cdlCancel" ).toInt()
    test simplement le code d'erreur de ta variable Err...Ce qui n'a pas d'influence, à priori, sur le nom sous lequel sera sauvé le fichier...

    A mon avis, essaie de savoir ce que fait exactement la méthode
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Pend.getFrmImprimer().RichTxtImpr.saveFile( Variable.sFile1 );
    --> si c'est une méthode de l'objet Pend.getFrmImprimer().RichTxtImpr, regarde quel est le type de cet objet... et trouve la définition des méthodes que tu peux lui appliquer.
    Je m'explique :
    --> autant la méthode "saveFile" accepte des paramètres facultatifs comme... le nom sous lequel enregistrer le fichier par exemple...

    Tu peux regarder aussi du côté de ton objet "Variable" ou "Variable.sFile1".. pour voir s'il n'existe pas des méthodes sur ces objets permettant de spécifier le nom sous lequel sauvegarder le fichier....

    En espérant que cela les pistes que je te donne aiguillent tes recherches....

  8. #8
    Membre très actif
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    146
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 146
    Par défaut
    En fait en saisissant un nom dans la boite de dialogue Enregistrer sous... , lorsque je clique sur Ok j'obtiens l'exception :

    java.lang.NullPointerException
    at MDIMenu.mnuDossierEnregSous_Click(MDIMenu.java:1041)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    1041:if( Err.getError().getNumber() != new Variant( Cmd ).getValue( "MSComDlg.cdlCancel" ).toInt() )
    Quant à :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Pend.getFrmImprimer().RichTxtImpr.saveFile( Variable.sFile1 );
    Le code de la methode saveFile est le suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
     
    package diamondedge.vb;
     
    import diamondedge.util.Variant;
    import java.awt.Color;
    import java.awt.Cursor;
    import java.awt.event.TextEvent;
    import java.awt.event.TextListener;
    import java.io.ByteArrayOutputStream;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.PrintStream;
    import javax.swing.JTextPane;
    import javax.swing.JViewport;
    import javax.swing.event.CaretListener;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    import javax.swing.event.EventListenerList;
    import javax.swing.text.AttributeSet;
    import javax.swing.text.EditorKit;
    import javax.swing.text.Element;
    import javax.swing.text.MutableAttributeSet;
    import javax.swing.text.SimpleAttributeSet;
    import javax.swing.text.StyleConstants;
    import javax.swing.text.StyledDocument;
    import javax.swing.text.StyledEditorKit;
    import javax.swing.text.rtf.RTFEditorKit;
     
    public class RichTextBox extends ScrolledComponent
      implements DocumentListener, DataBound, VbControl
    {
      private int U;
      protected JTextPane textpane = (JTextPane)getViewport().getView();
      protected StyledDocument doc;
      protected int selStart;
      protected int selFinish;
      protected String fileName;
      private String V;
      private DataSource T = null;
      public static final int ALIGN_LEFT = 0;
      public static final int ALIGN_RIGHT = 1;
      public static final int ALIGN_CENTER = 2;
     
      public RichTextBox()
      {
        super(new JTextPane());
        this.textpane.setEditorKit(new RTFEditorKit());
        this.textpane.setFont(Screen.getDefaultFont());
        this.textpane.setCursor(Cursor.getPredefinedCursor(2));
        this.doc = this.textpane.getStyledDocument();
        this.doc.addDocumentListener(this);
        setScrollBarPolicy(0);
      }
     
      public JTextPane control()
      {
        return this.textpane;
      }
     
      public String getFileName()
      {
        return this.fileName;
      }
     
      public void setFileName(String paramString)
      {
        this.fileName = paramString;
        try
        {
          loadFile(this.fileName);
        }
        catch (Exception localException)
        {
        }
      }
     
      public boolean isEditable()
      {
        return this.textpane.isEditable();
      }
     
      public void setEditable(boolean paramBoolean)
      {
        this.textpane.setEditable(paramBoolean);
      }
     
      public int getSelAlignment()
      {
        int i = StyleConstants.getAlignment(getAttributeSet());
        switch (i)
        {
        case 0:
          return 0;
        case 1:
          return 2;
        case 2:
          return 1;
        }
        return 0;
      }
     
      public void setSelAlignment(int paramInt)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        switch (paramInt)
        {
        case 0:
          StyleConstants.setAlignment(localSimpleAttributeSet, 0);
          break;
        case 1:
          StyleConstants.setAlignment(localSimpleAttributeSet, 2);
          break;
        case 2:
          StyleConstants.setAlignment(localSimpleAttributeSet, 1);
          break;
        default:
          StyleConstants.setAlignment(localSimpleAttributeSet, 0);
        }
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public boolean isSelBold()
      {
        return StyleConstants.isBold(getAttributeSet());
      }
     
      public void setSelBold(boolean paramBoolean)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setBold(localSimpleAttributeSet, paramBoolean);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public Color getSelColor()
      {
        return StyleConstants.getForeground(getAttributeSet());
      }
     
      public void setSelColor(Color paramColor)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setForeground(localSimpleAttributeSet, paramColor);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public String getSelFontName()
      {
        return StyleConstants.getFontFamily(getAttributeSet());
      }
     
      public void setSelFontName(String paramString)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setFontFamily(localSimpleAttributeSet, paramString);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public int getSelFontSize()
      {
        return StyleConstants.getFontSize(getAttributeSet());
      }
     
      public void setSelFontSize(int paramInt)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setFontSize(localSimpleAttributeSet, paramInt);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public float getSelHangingIndent()
      {
        return StyleConstants.getFirstLineIndent(getAttributeSet());
      }
     
      public void setSelHangingIndent(float paramFloat)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setFirstLineIndent(localSimpleAttributeSet, paramFloat);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public float getSelIndent()
      {
        return StyleConstants.getLeftIndent(getAttributeSet());
      }
     
      public void setSelIndent(float paramFloat)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setLeftIndent(localSimpleAttributeSet, paramFloat);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public boolean isSelItalic()
      {
        return StyleConstants.isItalic(getAttributeSet());
      }
     
      public void setSelItalic(boolean paramBoolean)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setItalic(localSimpleAttributeSet, paramBoolean);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public int getSelLength()
      {
        return (getSelectionEnd() - getSelectionStart());
      }
     
      public void setSelLength(int paramInt)
      {
        setSelectionEnd(getSelectionStart() + paramInt);
      }
     
      public float getSelRightIndent()
      {
        return StyleConstants.getRightIndent(getAttributeSet());
      }
     
      public void setSelRightIndent(float paramFloat)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setRightIndent(localSimpleAttributeSet, paramFloat);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public String getSelRTF()
        throws Exception
      {
        int i = getSelLength();
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(i);
        this.textpane.getEditorKit().write(localByteArrayOutputStream, this.doc, getSelectionStart(), i);
        localByteArrayOutputStream.close();
        return localByteArrayOutputStream.toString();
      }
     
      public void setSelRTF(String paramString)
      {
        this.textpane.replaceSelection(paramString);
      }
     
      public int getSelectionStart()
      {
        return this.textpane.getSelectionStart();
      }
     
      public void setSelectionStart(int paramInt)
      {
        this.textpane.setSelectionStart(paramInt);
      }
     
      public int getSelectionEnd()
      {
        return this.textpane.getSelectionEnd();
      }
     
      public void setSelectionEnd(int paramInt)
      {
        this.textpane.setSelectionEnd(paramInt);
      }
     
      public boolean isSelStrikeThru()
      {
        return StyleConstants.isStrikeThrough(getAttributeSet());
      }
     
      public void setSelStrikeThru(boolean paramBoolean)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setStrikeThrough(localSimpleAttributeSet, paramBoolean);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public String getSelectedText()
      {
        return this.textpane.getSelectedText();
      }
     
      public void replaceSelection(String paramString)
      {
        this.textpane.replaceSelection(paramString);
      }
     
      public boolean isSelUnderline()
      {
        return StyleConstants.isUnderline(getAttributeSet());
      }
     
      public void setSelUnderline(boolean paramBoolean)
      {
        SimpleAttributeSet localSimpleAttributeSet = new SimpleAttributeSet();
        StyleConstants.setUnderline(localSimpleAttributeSet, paramBoolean);
        setAttributeSet(localSimpleAttributeSet);
      }
     
      public String getText()
      {
        try
        {
          return this.doc.getText(0, this.doc.getLength());
        }
        catch (Exception localException)
        {
          System.out.println("RichTextBox.getText: " + localException);
        }
        return "";
      }
     
      public void setText(String paramString)
      {
        this.textpane.selectAll();
        this.textpane.replaceSelection(paramString);
      }
     
      public String getTextRTF()
        throws Exception
      {
        int i = this.doc.getLength();
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream((i < 40) ? 80 + i : i * 2);
        this.textpane.getEditorKit().write(localByteArrayOutputStream, this.doc, 0, i);
        localByteArrayOutputStream.close();
        return localByteArrayOutputStream.toString();
      }
     
      public void setTextRTF(String paramString)
      {
        this.textpane.setText(paramString);
      }
     
      public void loadFile(String paramString)
        throws FileNotFoundException, IOException
      {
        this.doc.removeDocumentListener(this);
        this.fileName = paramString;
        FileInputStream localFileInputStream = new FileInputStream(paramString);
        this.textpane.read(localFileInputStream, paramString);
        this.doc = this.textpane.getStyledDocument();
      }
     
      public void saveFile(String paramString)
        throws Exception
      {
        this.fileName = paramString;
        FileOutputStream localFileOutputStream = new FileOutputStream(paramString);
        this.textpane.getEditorKit().write(localFileOutputStream, this.doc, 0, this.doc.getLength());
        localFileOutputStream.close();
      }
     
      public void addCaretListener(CaretListener paramCaretListener)
      {
        this.textpane.addCaretListener(paramCaretListener);
      }
     
      public void removeCaretListener(CaretListener paramCaretListener)
      {
        this.textpane.removeCaretListener(paramCaretListener);
      }
     
      public AttributeSet getAttributeSet()
      {
        return this.doc.getCharacterElement(this.textpane.getCaretPosition()).getAttributes();
      }
     
      protected void setAttributeSet(AttributeSet paramAttributeSet)
      {
        setAttributeSet(paramAttributeSet, false);
      }
     
      protected void setAttributeSet(AttributeSet paramAttributeSet, boolean paramBoolean)
      {
        int i = this.textpane.getSelectionStart();
        int j = this.textpane.getSelectionEnd();
        if (paramBoolean)
        {
          this.doc.setParagraphAttributes(i, j - i, paramAttributeSet, false);
        }
        else if (i != j)
        {
          this.doc.setCharacterAttributes(i, j - i, paramAttributeSet, false);
        }
        else
        {
          MutableAttributeSet localMutableAttributeSet = ((StyledEditorKit)this.textpane.getEditorKit()).getInputAttributes();
          localMutableAttributeSet.addAttributes(paramAttributeSet);
        }
      }
     
      public void setSelection(int paramInt1, int paramInt2, boolean paramBoolean)
      {
        if (paramBoolean)
        {
          this.textpane.setCaretPosition(paramInt2);
          this.textpane.moveCaretPosition(paramInt1);
        }
        else
        {
          this.textpane.select(paramInt1, paramInt2);
        }
        this.selStart = this.textpane.getSelectionStart();
        this.selFinish = this.textpane.getSelectionEnd();
      }
     
      public int getTabOrder()
      {
        return this.U;
      }
     
      public void setTabOrder(int paramInt)
      {
        this.U = paramInt;
      }
     
      protected void fireDocumentChanged(DocumentEvent paramDocumentEvent)
      {
        Object[] arrayOfObject = this.listenerList.getListenerList();
        TextEvent localTextEvent = null;
        for (int i = arrayOfObject.length - 2; i >= 0; i -= 2)
        {
          if (arrayOfObject[i] != TextListener.class)
            continue;
          if (localTextEvent == null)
            localTextEvent = new TextEvent(this, 900);
          ((TextListener)arrayOfObject[(i + 1)]).textValueChanged(localTextEvent);
        }
      }
     
      public void changedUpdate(DocumentEvent paramDocumentEvent)
      {
        fireDocumentChanged(paramDocumentEvent);
      }
     
      public void insertUpdate(DocumentEvent paramDocumentEvent)
      {
        fireDocumentChanged(paramDocumentEvent);
      }
     
      public void removeUpdate(DocumentEvent paramDocumentEvent)
      {
        fireDocumentChanged(paramDocumentEvent);
      }
     
      public void addTextListener(TextListener paramTextListener)
      {
        this.listenerList.add(TextListener.class, paramTextListener);
      }
     
      public void removeTextListener(TextListener paramTextListener)
      {
        this.listenerList.remove(TextListener.class, paramTextListener);
      }
     
      public String getDataField()
      {
        return this.V;
      }
     
      public void setDataField(String paramString)
      {
        this.V = paramString;
      }
     
      public DataSource getDataSource()
      {
        return this.T;
      }
     
      public void setDataSource(DataSource paramDataSource)
      {
        if (this.T != null)
        {
          this.T.removeDataBound(this);
          removeTextListener(DataBoundRouter.dbRouter);
        }
        if (paramDataSource != null)
        {
          paramDataSource.addDataBound(this);
          addTextListener(DataBoundRouter.dbRouter);
        }
        this.T = paramDataSource;
      }
     
      public Variant getDataValue()
      {
        return new Variant(getText());
      }
     
      public void dataChanged(DataChangeEvent paramDataChangeEvent)
      {
        setText((paramDataChangeEvent.getValue() == null) ? "" : paramDataChangeEvent.getValue().toString());
      }
    }

  9. #9
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Citation Envoyé par youness78 Voir le message
    En fait en saisissant un nom dans la boite de dialogue Enregistrer sous... , lorsque je clique sur Ok j'obtiens l'exception :

    java.lang.NullPointerException
    at MDIMenu.mnuDossierEnregSous_Click(MDIMenu.java:1041)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    1041:if( Err.getError().getNumber() != new Variant( Cmd ).getValue( "MSComDlg.cdlCancel" ).toInt() )
    Comme l'autre nullpointerexception, la cause est facile à trouver. En l'occurence, soit Err, soit Err.getError(), soit new Variant( Cmd ).getValue( "MSComDlg.cdlCancel" ) est null. A toi de les tester individuellement pour savoir lequel pose probleme.

Discussions similaires

  1. aide Erreur java.lang.NullPointerException
    Par tare9 dans le forum Développement Web en Java
    Réponses: 43
    Dernier message: 31/05/2010, 17h02
  2. Réponses: 4
    Dernier message: 23/12/2008, 08h34
  3. Réponses: 8
    Dernier message: 11/05/2006, 19h32
  4. [JDIC]Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    Par kedare dans le forum Concurrence et multi-thread
    Réponses: 4
    Dernier message: 06/05/2006, 22h45
  5. java.lang.NullPointerException getparent()
    Par guano dans le forum AWT/Swing
    Réponses: 5
    Dernier message: 17/03/2006, 17h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo