Updating jframe

posted by | Leave a comment

I had a request to provide feedback to the user between when they made a change and when the GUI was updated with the final values.So I made this Log Handler that, in theory, would allow the behind the scenes processes to write to a JText Field when they started and finished and at appropriate times while they ran.import *; import *; import *; import *; import javax.swing.*; // // Set up a place to for all methods to call for logging results either to // the field in the main dialog or to a file.public final class Log Handler I was hoping to use the area as a status of where things were at the moment.Unfortunately, the posts often just say 'OK fixed it' and did not post the solution.They key is to have the line appear when I call the method to add the line.Though I guess I echo the thoughts from many other postings I have read on this subject in that it is quite frustrating that println() echos my messages exactly when I want them and it seems amazingly more difficult to have that same message appear in a text field at the desired time.To simplify things a little, the program has an Observable Value.

updating jframe-86updating jframe-87updating jframe-24updating jframe-25

It then notifies its observers and, depending on what value changed, one or a number of calculations are done, some of which are a bit time consuming, with the net result that other portions of the interface are updated.Then anywhere I felt the need to pass the status of my operations, I could just update the text.The problem is that I don't see any of the intermediate messages.The only difference I see is that if I create a new Thread, the messages no longer echo to the command prompt window until after the other processes finish and Windows starts beeping at me while the processes run. Am I correct that to get the result I am looking for I need to convert all the methods that might need to be called (there are a hundred or so) to extend Swing Worker, so that instead of running in the event thread they are running in another thread which then publishes back to the GUI running in the event thread?The problem is that I doubt most of what I wrote is thread-safe. Is part of the problem that I am trying to set Text with invoke Later in the middle of a method that is running in the event queue, resulting in the updates not occurring until the end? This a simple test that is supposed to post status as the operations are proceeding.

Leave a Reply

operaupdating ru