I'm writing a program to delimit data obtained through an RS-232 serial. There are three machines the program needs to receive data from, and three COM ports.
I've written some code to update a JTextArea in the programs interface to inform the user as to the port that the program is currently listening on, however the text area isn't updating based on the code and is remaining blank. The code is as such:
public String ComStat;
public void comDefine()
{
if (Serial.currPortId.getName() == null) {
ComStat = "NONE";
} else if (Serial.currPortId.getName() == "COM1") {
ComStat = "COM1";
} else if (Serial.currPortId.getName() == "COM2") {
ComStat = "COM2";
} else if (Serial.currPortId.getName() == "COM3") {
ComStat = "COM3";
} else {
ComStat = "NONE";
}
}
and for the jTextArea we have:
private JPanel createPanel(String text) {
JPanel panel = new JPanel();
JLabel lbl = new JLabel(text);
panel.add(lbl);
listenState = new JTextArea(ComStat);
listenState.setBorder(new BevelBorder(BevelBorder.LOWERED));
listenState.setLineWrap(true);
listenState.setWrapStyleWord(true);
add(listenState, BorderLayout.SOUTH);
panel.add(listenState);
return panel;
}
Any help on getting the JTextArea to actually display whether it's listening on a port and which port it's listening on would be much appreciated. I've cut out most of the code to make for easier reading of the area i'm actually having issue with.