I have this code to tell me if a port is open or not(available func). And I call that function in my GUI program like this:
String newavail = "" + available(9002) ;
JTextField tf1 = new JTextField("Is Port 9002(GWT Pet Store) available? \n" + newavail);
But if I close the port outside of the running GUI it doesn’t reflect this change right away. I read that you can use a revalidate() command, but how do you use that?
Assuming that the port is closed outside the Event Dispatch Thread, you should use
SwingUtilitiesto set the text of theJTextFieldinstance to reflect the availability status change.