Bonjour,
Dans mon programme que voici :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public SerialPort Connect(String Comm){
String selectedPort = (String) Comm;
portId = (CommPortIdentifier) hashmap.get(selectedPort);
CommPort commPort ;
try
{
commPort= portId.open("Port currently not owned", 2000);
serialPort=(SerialPort) commPort;
}
catch (PortInUseException e) {
// JOptionPane.showMessageDialog(this,"d");
}
return serialPort;
} |
Et sur la ligne
commPort= portId.open("Port currently not owned", 2000);
J'obtiens l'erreur
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
L'utilisation de cette méthode est un bouton Connecter
1 2
| SendRecPort d = new SendRecPort();
d.Connect(h); |
Quelqu'un saurait-il m'indiquer d'où peut venir le problème ?
Merci d'avance pour votre aide.
Partager