Questions tagged [invokeandwait]

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

SwingUtilities.invokeAndWait is a method provided by the Swing Library in Java in order to execute code on the AWT dispatching thread in a synchronous 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.
25 questions
0
votes
1 answer

SwingUtilities.InvokeAndWait() doesn't execute the runnable code

I'm writing a thread code that opens a server socket and that when reached by a connection asks the user to choose a directory. I've tried using the InvokeLater() and it works, but i have no control on when to retrieve the selected file directory,…
0
votes
0 answers

invokeLater strange call, after other methods

I am developing a library program and when I make a given successive actions, I get an unexpected row added to my books' JTable. The actions are this: launching of the program add a filter based on the commentaries (I have many filters, which are…
lolveley
  • 1,659
  • 2
  • 18
  • 34
0
votes
1 answer

Return Value from InvokeAndWait

I have a Java GUI application in which the view should provide a function which asks the user to choose a path for example. The function should be blocking until the user selected the path (or also if the user cancelled). As the function is not…
Semaphor
  • 900
  • 2
  • 12
  • 33
0
votes
1 answer

Swing Thread Violation

While debugging a strange behaviour in Swing I found this tools: CheckThreadViolationRepaintManager edited version by Alex Ruiz. (You must understand what this class does before answering my Question, thanks) And i fount a thread violation in my…
0
votes
1 answer

AutoComplete with GlazedLists

I'm using glazedlists for auto-completion but i want to ask something in this point. I have an arraylist for friendlist. People can be added to friendlist or can be removed from friendlist by clicking add or remove button. Data of friendlist is…
kapozade
  • 137
  • 1
  • 1
  • 11
0
votes
1 answer

Code structure in a GUI swing multihreaded application

I'm new to Java and threads in general and I have a following GUI application in java: In a frame, a user clicks mouse anywhere and an image appears. Once image appears, a real-time timer starts running, updating itself in a jLabel Depending on…
ysh
  • 9
  • 1
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
1 answer

Java Swing: Swing Worker, invokeAndWait and Overlapping JLabels

Hey guys I've come with 2 problems, both being Java Swing related. I am developing a card game in Java. I use arreays lists of type to hold the values of each card and I have a main Play() method that calls updates to the GUI using invokeLater and…
Sean
  • 1
  • 1
  • 4
-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
-2
votes
1 answer

java - string return method is called before any value is assigned to string

My application is supposed to read and write to a Serial Port. The data is read in the EventListener of the PortReader class. I wish to assign this data to a global String variable (private String sPortReaderString) for further use. The global…
jadrijan
  • 1,438
  • 4
  • 31
  • 48
1
2