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
0
votes
2 answers

Updating a JProgressBar while doing a long comparison

I got a serious problem with my recent project: I am doing a long comparison in a methode called writer(...) and it takes about 20 seconds. The methode is decalred in the View class, where my GUI elements are setted also. While the method is…
D S
  • 5
  • 1
  • 3
0
votes
1 answer

java - How to use invokeLater to synchronize some IO with UI

In my java application I am using swing to implement the UI. There is a button called theButton which is engaged with some IO operation in the following timely steps : the button originally has the text "Click to connect" then before the connect…
C graphics
  • 7,308
  • 19
  • 83
  • 134
0
votes
1 answer

Exception in thread "AWT-EventQueue-0" despite of using invokeLater

I'm trying to update a JTable (here: prosumerTable) programmatically, using SwingUtilities.invokeLater to start it out of the EventDispatchThread- to be exact i have to replace the content completely, hence i'm just removing all rows and adding new…
0
votes
2 answers

Explain Runnable and Invoke()

Can someone please explain this below written code ? public void setSelectedFolder(final File f){ if(f != null){ Runnable r=new Runnable(){ public void run(){ target.setText(f.toString()); } …
Rishi
  • 55
  • 6
0
votes
0 answers

event dispatch thread

what is difference between event dispatch thread and any normal thread like main thread in creation swing compoments and handling events , what is features of event dispatch thread over main thread by coding , what is difference between these two…
user1841718
  • 187
  • 1
  • 4
  • 15
0
votes
2 answers

Document not updating for combo box Java

I am writing Bing/Google instant search kind of feature in combo box, so this combo box provides suggestions to the user based on what he has typed. The program works like a charm but their is one bug that I am unable to figure out how to solve. The…
James Aflred
  • 87
  • 2
  • 5
  • 12
0
votes
3 answers

Custom Modal Dialog

I am creating my own dialog which is basically a JPanel set as the glasspane on a JFrame. I want to make my dialog modal in the sense that all the code after the setVisible() is not executed while the dialog is visible and once the dialog is closed,…
bouncer
  • 173
  • 10
0
votes
1 answer

invoke and wait which interacts with a sub class

I have found many fine examples of invoke later and invoke and wait across the site. However the issue that I have is that the I would like to get a response from a class which is called by the main method Could any one provide some code that a main…
Keith Spriggs
  • 235
  • 1
  • 4
  • 10
0
votes
2 answers

InvokeLater Freezes the GUI

I'm trying to simulate a simple thermostat, using multi-threading. The thermostat should increase the temperature in order to reach the value that the user requested for which is "Max" value in the code below. I have two thread, one in charge of…
Afflatus
  • 933
  • 1
  • 12
  • 39
0
votes
1 answer

Using invokeLater( ) in UiApplication

Can i include my try catch block with invokeLater statement in UiApplication for blackberry. What is the exact purpose of using an invokeLater mothod.And how is it to be invoked? Here is the code UiApplication.getUiApplication().invokeLater(new…
learning_fly
  • 382
  • 1
  • 2
  • 11
0
votes
3 answers

Class not found when using SwingUtilities.invokeLater in OSGi Bundle

(EDIT: Problem is solved - see details at the end) I want to create a Swing JFrame with a WindowAdapter in an OSGi Bundle. When I do this using SwingUtilities.invokeLater, the WindowAdapter class is not found. Without invokeLater it works. What do…
Rainer Schwarze
  • 4,725
  • 1
  • 27
  • 49
-1
votes
1 answer

DocumentListener method being called repeatedly

I've made a documentlistener that will call a method when text is inserted. It works but the problem is that it acts as if it's in a loop and is kept being called. The method uses swingutilties.invokelater from inside the method. private void…
Johnnie
  • 21
  • 4
-1
votes
2 answers

GUI not updating after calling GUI method in another thread

EDIT: Simplified my code. This is the main class that initialises the GUI and Server threads. public class Main { public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException,…
AnonymousAngelo
  • 996
  • 3
  • 15
  • 37
-1
votes
2 answers

making pop up window by using SwingUtilities.invokeLater

I am writing a turn-based game on the internet. I try to pop up a window that should be in front until the input stream is ready. I created smth like this, but it seems that it does not work. class CustomBlockerDialog extends JDialog { /** * …
slawic
  • 1
  • 1
-1
votes
4 answers

Why invokeAndWait() is preferred for applets and not for standalone applications?

The java docs says: In an applet, the GUI-creation task must be launched from the init() method using invokeAndWait(); otherwise, init() may return before the GUI is created, which may cause problems for a web browser launching an applet. What is…
Surender Thakran
  • 3,958
  • 11
  • 47
  • 81
1 2 3 4 5 6 7
8