我正在学习 Java,我正在尝试做这个 settext 工作,但我没有得到
public static void main(String args[]) throws Exception { try { (new Visual()).connect("COM4", "1"); (new Visual()).connect("COM6", "2"); } catch ( Exception e ) { e.printStackTrace(); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Visual().setVisible(true); } }); }
void connect ( String portName, String linha ) throws Exception
{
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
if ( portIdentifier.isCurrentlyOwned() )
{
System.out.println("Error: Port is currently in use");
}
else
{
CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
if ( commPort instanceof SerialPort )
{
SerialPort serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
status_porta2.setText(portName);
.....
}
}
}
我正在搜索更改此功能中的标签文本,但不起作用..发生了什么?谢谢