例如,在下面的代码中,我想更改 JTextField 以显示端口即时扫描是否打开,但我不知道该怎么做。也许我需要一些辅助方法?
public void actionPerformed(ActionEvent arg0) {
console.setText("Starting check\n" +
"Start = "+stopServTf.getText()+
"\nStop ="+stopServTf.getText()+
"\nPort Start ="+startPortTf.getText()+
"\nPort Stop ="+stopPortTf.getText());
PortScanner p= new PortScanner(Integer.parseInt(startPortTf.getText()),
Integer.parseInt(stopPortTf.getText()),startServTf.getText());
}
和其他方法/构造函数
public PortScanner(int portStart, int portStop ,String ip) {
for (int i = portStart; i <= portStop; i++) {
try {
Socket ServerSok = new Socket(ip, i);
setString(i);
//System.out.println("Port in use: " + i);
ServerSok.close();
} catch (Exception e) {
}
setStrinN(i);
System.out.println("Port not in use: " + i);
}
}
public static String setString(int i) {
return "Port in use: " +i;
}
public static String setStrinN(int i){
return "Port not in use: "+i;
}
所以我想发送给console.setText();