edt

Java - SwingWorker - problem in process() method

I am using javax.swing.SwingWorker for the first time. I want to update a JLabel from the interim results published by the swing worker as follows: publish("Published String"); Now to update the JLabel, I have coded the following: process(List<String> chunks) { if (chunks.size() > 0) { String text = chunks.get(chunks.siz...

Swing verify code on event dispatch thread at runtime

Are there any libraries that instrument code to verify that methods called on swing components are called on the event dispatch thread? It probably wouldn't be too difficult to write some basic code for doing this, but I'm sure there are edge cases and whatnot that other people have handled. I'm looking for this at runtime though, not fo...

Java: does the EDT restart or not when an exception is thrown?

(the example code below is self-contained and runnable, you can try it, it won't crash your system :) Tom Hawtin commented on the question here: http://stackoverflow.com/questions/3018165 that: It's unlikely that the EDT would crash. Unchecked exceptions thrown in EDT dispatch are caught, dumped and the thread goes on. Can someone e...

Java Swing - Can i run 2 GUI actions in the EDT ?

In a JDialog, when user clicks a JButton i want to execute 2 GUI actions in the EDT : Showing another small JDialog with a busy icon in it to tell the user "Please wait while the wrong process ends". Inserting a big number of records in a JTable. When i try to execute both actions the "please wait" dialog blocks the inserting process...

Static Thread Analysis: Good idea?

I help maintain and build on a fairly large Swing GUI, with a lot of complex interaction. Often I find myself fixing bugs that are the result of things getting into odd states due to some race condition somewhere else in the code. As the code base gets large, I've found it's gotten less consistent about specifying via documentation whi...

Does java.awt.Desktop need to be used on the EDT?

Looking around I couldn't find a requirement that java.awt.Desktop is required to be used on the EDT, and I couldn't think of a reason why it should be, but I couldn't find anywhere that explicitly says it is fine, so I thought I would ask, since it is an awt class, after all. Is there anywhere that says officially, one way or the other...

GUI layer vs Code layer vs Swing

I always coded console applications and learned some basic UML/patterns skills, using C++. Now I decided to move to Java and add GUIs to my programs. The first question is how to handle the GUI layer in the program desing. I mean, how I should separate all the GUI code (adding components, basic event handling) with the code that really...

JFrame and why stay running

Why if I create a JFrame then the program still runs until (i.e) I close it with the small "exit button" of the window? I looked for this answer and I failed. The only thing I guessed is that when I do "new JFrame()" it's like an special "new", that keeps a reference of the object in the EDT, so it will always be referenced (even if was...

Java 1.5 Swing: what is the correct way to perform long-running operation outside the EDT?

In a desktop Java 1.5 application (it has to run on a lot of MacOS X machines that will nerver see a 1.6 VM due to Apple politics) what is a correct way to perform a lengthy computation outside the EDT? Say, for example, when the user clicks on a button that starts an operation: I get the notification on the EDT and I want to run some m...

Where is the event dispatch thread called?

I read that all the code which constructs Swing components and handles Events must be run by the Event Dispatch Thread. I understand how this is accomplished by using the SwingUtilities.invokeLater() method. Consider the following code where the GUI initialization is done in the main method itself public class GridBagLayoutTester ...

EDT editor - a modern approach?

I used the EDT editor on VMS very long time ago. Is there modern implementation of this excellent text editor available? If so, are there source codes? Maybe it is circumvented by Emacs and Vim? Thank you ...

How to retrieve a value that must be computed on another thread

There are many cases where thread A requires a value that must be computed on thread B. (Most commonly, B == EDT.) Consider this example: String host; SwingUtilities.invokeAndWait(new Runnable() { public void run() { host = JOptionPane.showInputDialog("Enter host name: "); } }); openConnection(host); Of course, this ...