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
3 answers

In Java using Swing, how can I know when all threads launched with invokeLater have finished?

Inside a createAndShowGUI() method called by javax.swing.SwingUtilities.invokeLater like this...: public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { …
Redoman
  • 3,059
  • 3
  • 34
  • 62
0
votes
1 answer

How to bind a JProgressBarr progress to a JButton preventing it from freezing?

that's the code i'm using, for the MAIN class: public class Main { public static void main(String[] args) throws Exception { MAINFRAME.GUI(); } } now that's about the mainframe class that is called from the main class: public class MAINFRAME…
ApprenticeGeek
  • 177
  • 1
  • 1
  • 7
0
votes
1 answer

my java swing application jcomponents won't either paint, repaint only after calculations done?

i have a voice recognition system, this is the listen(button) function private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: jButton1.setIcon(…
malek h
  • 5
  • 7
0
votes
3 answers

how to run method from a Type every 10 miliseconds

I'm trying to replicate MonoBehaviour of the Unity 3D engine. I'm using monodevelop on Linux, and most testing will be done in Windows Unity 3D engine editor. more about MonoBehaviour.Update can be read here I want to invoke the Update method on all…
MilitaryG
  • 75
  • 1
  • 9
0
votes
2 answers

JProgressBar not working properly

So my JProgressBar I have set up doesn't work the way I want it. So whenever I run the program it just goes from 0 to 100 instantly. I tried using a ProgressMonitor, a Task, and tried a SwingWorker but nothing I tried works. Here is my program: int…
ItsRainingHP
  • 139
  • 1
  • 4
  • 18
0
votes
2 answers

Identifying the AWT thread

I have a class, which decorates JTextComponent from Swing. Methods that it contains can be called from any thread, so I have to ensure, that code which works with JTextComponent will be performed by AWT thread. The second requirement is, that…
0
votes
1 answer

Swing GUI; Able to resize window while running long process but panels inside main frame won't update until process is complete

I trying to use SwingUtilities.invokelater to allow me to resize and move my programs window about while my long process is running. What I'm getting is that I'm able to move the window and resize it but the components inside don't update e.g. If I…
Peck3277
  • 1,383
  • 8
  • 22
  • 46
0
votes
1 answer

How to prevent Deadlock when updating Swing components using swing timers and invokeLater?

Can deadlock happen for an arbitrary synchronised method which updates some Swing components if the threads which call to this method all use Swing Timer or SwingUtilities.invokeLater() . I think that it will not be necessary to call invokeLater()…
Johnny
  • 1,509
  • 5
  • 25
  • 38
0
votes
2 answers

Updating the GUI in real time from SwingWorker

Ok, this is a follow-up question to my question from yesterday, "Error handling in SwingWorker." In consideration of the fact that it might be ok to call SwingUtilities#invokeAndWait() inside of SwingWorker#doInBackground(), I want to push it a step…
ryvantage
  • 13,064
  • 15
  • 63
  • 112
0
votes
1 answer

What if I don't use SwingUtilities.invokeLater?

When I start my GUI interfaces, what can happen if I don't use invokeLater? Does that mean all rest of the GUI paints/updates/etc. will be in the main thread? Will calling a repaint outside of an invokeLater make all subsequent calls fall into the…
Mathew Kurian
  • 5,949
  • 5
  • 46
  • 73
0
votes
1 answer

i cannot change two progressBar immediately

I want to change two progressBar immediately. but I can't. what I'm saying is.. nextButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { …
0
votes
1 answer

Strange Polymorphism Need

I have a class with an eventOccurred that does its work inside SwingUtilities.invokeLater (in order to be on the EDT). This class will be extended. I want to force anything extending this class to also put their eventOcurred work inside…
shedhorn
  • 3
  • 2
0
votes
1 answer

How to check invokelater is done

In the code below I want to do something after invokeLater is done. 1) I can not use invokeAndWait due to setModel being called by dispatcher. 2) I can not change the value of a final variable inside thread! then how can I wait for involeLater to be…
C graphics
  • 7,308
  • 19
  • 83
  • 134
0
votes
3 answers

The SwingUtilities.invokeLater() method in a Java Swing program

I am studying Java Swing and I have some questions related to this simple code tutorial that I am reading: package com.andrea.execute; import javax.swing.JFrame; import javax.swing.SwingUtilities; /* An istance of a SimpleExample class is a JFrame…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
0
votes
1 answer

Java requestInWindow sometimes does not work

I've got a problem with requestInWindow in Java where I need to focus on a textfield when its container becomes visible. It works sometimes, but there are those times when a gui will run slowly because of os operations. For example if an antivirus…
Maposa Takalani
  • 338
  • 1
  • 5
  • 17