j ai une 2 classe definit comme suit dont le premier est la principale c est qui contien donc un main et le 2eme construit un menuBar
moi je voudrais que lorqu on appuie sur un boutton de menuBar on affiche un message dans le JtexteArea de la classe principale

Mais j ai une exception de pointer null

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
 
 
 
public class Principale extends Jframe {
 
   public JTextArea text;
 
    public  Principale (){
 
    ..... Menu m= new Menu();
         setJMenuBar(m)
 
         texte = new JTextField("ZONE DES RESULTATS ");
 
...... ensuite ajouter texte aau container de l interface
 
}
}
 
 
 
 
 
 
public class menu extends JMenuBar
                          implements ActionListener {
 
  .....construccteur d un menu
 
public void actionPerformed(ActionEvent evt) {
 
     if (evt.getSource() == bouton1 ) { 
 
                Principale temp = new Principale();
               temp.texte.setText("un exemple d ecriture sur le texte")
           }
}




java.lang.NoSuchFieldError: zoneAffichage
at MenuFenetre.actionPerformed(MenuFenetre.java:107)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
86)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1
113)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
d(BasicMenuItemUI.java:943)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)