Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Bonsoir à tous !!
je sollicite votre aide, parce que vraiment je bloque, je n'arrive pas à voir ou se situe l'erreur. j'ai aussi vu les autres discussion qui aborde le même problème mais malheureusement... =(
Donc voilà l'erreur que me renvoie Eclipse
Citation:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Chat.run(Chat.java:711)
at Chat.changeStatusNTS(Chat.java:607)
at Chat$5.actionPerformed(Chat.java:268)
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.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)
et voilà les méthodes concernées :
*at Chat$5.actionPerformed(Chat.java:268)
Dans mon interface y'a le bouton connecter :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| pane = new JPanel(new FlowLayout());
ActionAdapter buttonListener = new ActionAdapter() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("connect")) {
changeStatusNTS(BEGIN_CONNECT, true);
}
}
};
connectButton = new JButton("Connexion");
connectButton.setMnemonic(KeyEvent.VK_C);
connectButton.setActionCommand("connect");
connectButton.addActionListener(buttonListener);
connectButton.setEnabled(true);
connectButton.setPreferredSize(new Dimension(150, 30));
pane.add(connectButton);
optionsPane.add(pane); |
*at Chat.changeStatusNTS(Chat.java:607)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| static void changeStatusNTS(int newConnectStatus, boolean noError) {
// Change state if valid state
if (newConnectStatus != NULL) {
connectionStatus = newConnectStatus;
}
// If there is no error, display the appropriate status message
if (noError) {
statusString = statusMessages[connectionStatus];
}
// Otherwise, display error message
else {
statusString = statusMessages[NULL];
}
// Call the run() routine (Runnable interface) on the
// current thread
tcp.run();
} |
*at Chat.run(Chat.java:711)
Code:
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
| public void run() {
switch (connectionStatus) {
case DISCONNECTED:
connectButton.setEnabled(true);
ipField.setEnabled(true);
portField.setEnabled(true);
hostOption.setEnabled(true);
guestOption.setEnabled(true);
statusColor.setBackground(Color.red);
break;
case DISCONNECTING:
chat.setSize(400,400);
chat.setContentPane(fenetre_connection());
chatLine.setEnabled(false);
statusColor.setBackground(Color.orange);
break;
case CONNECTED:
chat.setSize(900,700);
chat.setContentPane(fenetre_chat());
chatLine.setEnabled(true);
statusColor.setBackground(Color.green);
break;
case BEGIN_CONNECT:
connectButton.setEnabled(false);
loginField.setEditable(false);
statusColor.setBackground(Color.orange);
break;
}
// try{
chatText.append(toAppend.toString());
chat.repaint();
// } catch (NullPointerException e){}
//
//
} |
Je vous remercie infiniment de votre éventuelle aide ...:oops: