例如,在下面的代码中,我想修改 JTextField 来显示端口的扫描是否打开, 但我不知道该如何操作。 也许我需要一些辅助方法?
public void actionPerformed(ActionEvent arg0) {
console.setText("Starting check
" +
"Start = "+stopServTf.getText()+
"
Stop ="+stopServTf.getText()+
"
Port Start ="+startPortTf.getText()+
"
Port 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;
}
所以我要发送到 condole. setText ();