event-dispatch-thread

Java: is there a SwingUtilities.invokeNowOrLaterIfEDT(...) or similar?

(be sure to read the edit below, this question is obviously confusing I'm sorry about that) Here's a typical SwingUtilities.invokeLater call: SwingUtilities.invokeLater( new Runnable() { public void run() { ... } } ); Now I'd like to have what would be a SwingUtilities.invokeNowOrLaterIfEDT. Of course I could use ...

Returning values from Swing using invokeAndWait

I've been using the following approach to create components and return values from Swing to/from outside the EDT. For instance, the following method could be an extension to JFrame, to create a JPanel and add it to the parent JFrame: public JPanel threadSafeAddPanel() { final JPanel[] jPanel = new JPanel[1]; try { Even...

Trouble getting Swing to refresh JLabel (apparently on event dispatch thread)

I have this action listener: this.newGameButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent a) { MokkiGUI.this.game = newGameQuery(); MokkiGUI.this.AI = new AIPlayer(MokkiGUI.this.game.getBoard()); MokkiGUI.this.boardLabel.setText(""); MokkiGUI.this.boardLabel.repaint(); refresh...

How can I run all methods of a class on Event Dispatch Thread

I've created a Swing component which has several methods. Now I want all methods of this class be run on Event Dispatch Thread (EDT), while callers are on Worker threads. The only solution currently in my mind is this: for each method public void a(params) on this class, I should rename it to private void aOnEDT(params) and ...

Displaying JWindow in the event dispatching thread

What I am trying to do is have a small splash screen appear while my program is loading something. This is what I have: SplashScreen.showSplashScreen(); // Do stuff that takes time. SplashScreen.hideSplashScreen(); All the showSplashScreen() method does is create a new JWindow in the middle of the screen and make it visible. Now this...

Problem with updating the jTextArea

I am writing a RMI chat program. In my program I am able to receive and send messages, but i am not able to display it in the TextArea. I am not sure what is the error. I tried using Event Dispatch method also. It doesn't help. public class client extends javax.swing.JFrame implements inter { public client() { initComponents(); } ...

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 ...