I'd rather you post the salient code here. I'm of the philosophy that if you're asking for free advice, the onus is on you to try to make it as easy as possible for us to be able to help you. I prefer an SSCCE, but will review a reasonable amount of non-SSCCE code if it is written so that it is easy to understand. Also, please go into greater detail on your code's expected and observed behavior. Again, what happens if the user handles the dialogs and they go away?

05-28-2012, 10:33 PM

daxserver

Re: JTextFields not updating

Sorry for posting code like that. It is scrambled as many parts all over my program. So it made me hard to post as short and simple as possible as I can. And I compiled on JDK 7

In b.java(second code in the first post of thread) -> the JOptionPane is written after the ipfield and portfield are updated with setText(). When I run this code these fields are actually updated with the desired data (my external ip and opened port for socket [getLocalPort()] ) and then the message dialog appears. //But as long as the user doesn't click the ok button, the socket.accept() is not called.

In c.java(first code)-> the JOPane is written before the ipfield and portfield are updated. Running this, first the dialog comes and user clicks ok. The next line in the code is to update the ipfield and portfield before the socket.accept() is called but it is not happening - they are not updated. But when the timeout occurs and exception is thrown then these two fields are updated. (If there is no timeout then those two fields are never updated)

I didn't understand why they were not updating.

//I am unable to attach screenshot. When I click on "Manage Attachments" a new empty window opens up.

05-28-2012, 10:34 PM

Fubarable

Re: JTextFields not updating

It sounds like you've likely got a threading issue. Are you using a SwingWorker for your background thread work? If not, look into doing this.

05-28-2012, 10:38 PM

daxserver

Re: JTextFields not updating

Quote:

Originally Posted by Fubarable

It sounds like you've likely got a threading issue. Are you using a SwingWorker for your background thread work? If not, look into doing this.