Questions tagged [invokelater]

A method provided by the SwingUtilities class in Java that executes asynchronously code on the AWT event dispatching thread in order to correctly manipulate UI elements.

SwingUtilities.invokeLater is a method provided by the Swing Library in Java in order to execute code on the AWT dispatching thread in an asynchronous fashion. As in the majority of graphical toolkits, an arbitrary thread is not allowed to update directly the UI but should asks the UI thread to execute it on its behalf.

Similar constructs exists in other UI toolkits (for example, in .NET there are Invoke/InvokeRequired methods in Windows Forms and the Dispatcher object in WPF).

This tag should be used to emphasize that invokeLater is used in the code, thus ruling out concurrency issues on the UI.

Related tags:

Additional resources:

  • The Java Tutorial has a chapter on invokeLater and invokeAndWait.
120 questions
1
vote
3 answers

Writing to JEditorPane fast

In the code below I would like to write onto JEditorPane the numbers 0 to 10000. However, the JEditorPane does not display anything unless either it is completely done ( printing all 0 to 10000 at once) or when the os gives it time to refresh and…
C graphics
  • 7,308
  • 19
  • 83
  • 134
1
vote
1 answer

Weird thing with GUI and Threads in java

Given the following code: public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { ClientGUI gui = new ClientGUI(); gui.start(); } …
izac89
  • 3,790
  • 7
  • 30
  • 46
1
vote
1 answer

SwingUtilities.invokeLater() displaying just during one frame

I'm using Swing in order to create a little java 2D game. I only try to display an image. Since i'm not on the EDT I'm using SwingUtilities.invokeLater() to do the stuff. When I use it, image is not displayed (in fact it's displayed during few…
Pierre Criulanscy
  • 8,726
  • 3
  • 24
  • 38
1
vote
2 answers

Run Thread only when whole UI is up

I want to run a thrad only when whole UI is up properly ie. all component's paint() is completed. I tried with SwingUtilities.invokeLater(), but still the thread runs before whole UI is up or when all component's paint() is not complete. Is it…
1
vote
0 answers

Is static assignment of Swing object OK?

For example: can this be used in a class MyPane? public class MyPane extends JRootPane{ public static JCheckBox Debug= new JCheckBox("Debug"); .... } Will Swing have problem? Should we always put these assignment in invokeLater? Thanks.
Hai Bi
  • 1,173
  • 1
  • 11
  • 21
1
vote
5 answers

Cannot update Swing component under a heavy process

I am running a very heavy process under an anonymous SwingWorker thread. In the meantime, I'm reporting progress to the GUI using a progress bar. However, Swing threading is doing me in. It's simply not updating anything in time. I'm not sure how to…
Redandwhite
  • 2,529
  • 4
  • 25
  • 43
1
vote
1 answer

SwingUtilities.invokeLater not working as expected

I am working on a concurrent canvas written in Java which will make the users think that they are drawing on the canvas in parallel. In order to achieve the user perceived parallelism, I get them to create these Runnable objects that I go ahead and…
freakii
  • 27
  • 7
1
vote
3 answers

Using Event Queue to execute a simple method in main()

I am working on a Java application that was developed by some guy as part of a research project. Following is the main method: public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public…
Ankit
  • 6,772
  • 11
  • 48
  • 84
0
votes
2 answers

Blackberry screen navigation

I have a Screen name DownloaderScreen when the screen start it will start download some file and when download is complete it will go forward to next screen autometically. I using the following code. public DownloaderScreen() { …
dev_android
  • 8,698
  • 22
  • 91
  • 148
0
votes
0 answers

How do I use the InvokeLater to show all my components in JFrame?

I am trying to show different JPanels using JSplitPane. I use SwingUtilities.InvokeLater to show all the components to avoid sluggishness in UI. But the JPanel on the bottom which is pinkPane doesn't show until I resize the window. I tried my chance…
Mehmet
  • 118
  • 7
0
votes
1 answer

Does java consolidate multiple repaint() calls into a single repaint()?

I am receiving hundreds of events per second for a few seconds, each updates my model. If I call repaint() inside of invokeLater() after every event, will repaint be called hundreds of times per second? Is it smart enough to realise that it has…
AlexHomeBrew
  • 117
  • 9
0
votes
0 answers

Why code never ends which contains EventQueue.invokeLater?

I have a main class : MyMainSDK public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { MyMainSDK frame = new MyMainSDK(); …
CompEng
  • 7,161
  • 16
  • 68
  • 122
0
votes
1 answer

DatagramSocket UDP Server Swing InvokeLater not working

Trying to make a DatagramSocket UDP server/client chat app but having some problems getting the GUI to update after receiving a packet with a DatagramPacket. Here's my code; the only thing I left out, which I thought was irrelevant, was my…
Jacob
  • 439
  • 6
  • 19
0
votes
1 answer

GUI JButton Not Updating On Time

I'm working with code that is essentially a file mover program. What I'm attempting to do is after the user clicks the submit button which calls the file mover, the text of the button would change to 'Working'. I have a basic understanding of why it…
Marshal Alessi
  • 105
  • 2
  • 2
  • 11
0
votes
0 answers

using invokelater wit runnable method

Sorry if this question stupid but i am trying to learn java and do some tuts on Swing. On all the tuts it is demonstrated on how to use the EventQueue.invokelater Method and pass it a Runnable object and override the run Method of it. Code of one…
m0lari
  • 1
  • 1