adrienr11vdv
Messages postés99Date d'inscriptionjeudi 13 juillet 2006StatutMembreDernière intervention16 avril 2009
-
7 févr. 2008 à 18:48
adrienr11vdv
Messages postés99Date d'inscriptionjeudi 13 juillet 2006StatutMembreDernière intervention16 avril 2009
-
7 févr. 2008 à 19:41
Bonjour à tous,
pour une question d'organisation, je désire séparer le code graphique du reste. Pour cela, j'ai crée un package qui gère les JFrame et un autre package qui gère les Controller.
voici ma classe de controlle:
public class LogController implements ActionListener {
private LogVue logVue;
private Tout tout;
public LogController(LogVue logVue){
this.logVue = logVue;
logVue.getJb_valid().addActionListener(this);
}
public void actionPerformed(ActionEvent act) {
Object src = act.getSource();
// la source est le bouton valider ::
if ( src.equals(logVue.getJb_valid()) ){
tout.setVisible(true);
}
voici la classe LogVue
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
LogVue inst = new LogVue();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
});
}
public LogVue() {
super();
initGUI();
control = new LogController(this);
}
public JButton getJb_valid() {
return jb_valid;
}
......}
et voici l'erreur:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Controller.LogController.actionPerformed(LogController.java:39)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
plop3000
Messages postés135Date d'inscriptionmercredi 23 mai 2007StatutMembreDernière intervention 7 avril 20121 7 févr. 2008 à 18:56
Bonjour,
je crois que tu n'initialise pas ton objet "tout". Donc quand tu fais "tout.setVisible(true)" ça plante. Il faut que tu fasse un new sur "tout" à un moment ou un autre.