Questions tagged [event-dispatch-thread]

The event dispatch thread, or EDT, is a special background thread which handles events from the Java GUI event queue. Swing and Android have different implementations but they are similar in concept.

This thread must never be stalled with some computationally intensive or otherwise slow task (like networking), as the GUI stops responding to user input until the call returns.

As Java GUI environments are not thread-safe, it is the only thread that can safely touch GUI components (instantiating and updating GUI components, including setting values for text fields and the like). If any other thread must do this, this should be done through a wrapper method that runs on the EDT. In Swing, the wrapper method is SwingUtilities.invokeAndWait or SwingUtilities.invokeLater. In Android, Activity.runOnUiThread serves the same purpose.

775 questions
-1
votes
2 answers

Progress bar using for loop as simulation

I am trying to simulate a progressbar process using a for loop. The whole loop represent 100% so as the loop increases, the progressbar should also increase until the loop is done it will be 100% However in netbean UI the progress bar doesnt show as…
BeyondProgrammer
  • 893
  • 2
  • 15
  • 32
-1
votes
1 answer

Exception when try to apply and run substance theme in netbeans

I added substance theme to my swing application and tried to run it, and it works . but I keep getting this exception while running it. can someone tell me how to fix it?…
-1
votes
2 answers

Using Sleep method inside a For loop (on hold)

I working on a program that prints 100 numbers in a jTable. Also, there will be an if statement to validate the results, and will set a jPanel in a Specific color according to the value that is printed. I need to print those values a little bit…
E B
  • 5
  • 2
  • 5
-1
votes
1 answer

Bug with Thread.pause

This is my code: private void jButton5MouseClicked(java.awt.event.MouseEvent evt) { this.jButton5.setText("VietNam"); try { Thread.sleep(10000); } catch (InterruptedException ex) { …
-1
votes
4 answers

Why doesn't setText work for JLabel component?

I have a JLabel which I want to change momentarily, here is the code I have written to do so: infoLabel.setText("Added"); try { TimeUnit.MILLISECONDS.sleep(300); } catch(InterruptedException ex) { } infoLabel.setText("Action"); //funny part is…
Snedden27
  • 1,870
  • 7
  • 32
  • 60
-1
votes
1 answer

java swing frame not closing with X

hello guys i am working on program in which i have to perform a certain task after which i can close the window also.. obviously but it is not closing the window... my main class is like public class laudit { public static void main(String[]…
-1
votes
1 answer

Progress bar not updating during a loop

My progress bar doesn't update until the loop has finished? Why is this? for (String theURL : IPArray) { URL url = new URL(theURL); InetAddress address = InetAddress.getByName(url.getHost()); String temp = address.toString(); String…
-1
votes
1 answer

Making my ERROR message in GUI disappear

I have this simple GUI that ask for a string and then write it to a text file but if no input is given the JLabel shows an error message and i want that error message to stay for 5 seconds import java.awt.Color; import…
CYBERSIX
  • 347
  • 1
  • 7
  • 19
-1
votes
1 answer

why textbox is not auto update in java?

below my code i code wright for gps is give me coninue data on 4800 baud rate this data display continue by "System.out.println(st)" but same data not dispaly in a.setText(st) where a is Textbox variable. some know how to my textbox update like…
-1
votes
2 answers

Break after Thread.interrupt() does not work

The following code it for a SlotMachine GUI with MultiThreads. When I hit the stop button in the app. I would expect each thread to be interrupted, go into the catch, print an error, continue for a few more "turns" then break. Unfortunately when…
-1
votes
1 answer

Why the following lines don't block the EDT?

public lyridisplay (java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents();//to create a JList /* folowing code inside try preforms DB operations*/ /*It will return array of string s*/ try { …
joey rohan
  • 3,505
  • 5
  • 33
  • 70
-1
votes
2 answers

GUI program could not update

I have question about my homework the coin program. We need write a small GUI program which could flip the coin and can show the current money. I wrote almost everything, but I still have some problem to update two JLabel status and it seems like…
JavaLeave
  • 225
  • 1
  • 5
  • 14
-2
votes
1 answer

How to visualize sorting algorithms?

I want to sort these coloured bars using different algorithms. . I have created a JFrame and added eight buttons and one JPanel. In the panel I have created a bar chart of an array. I want to sort this bar chart visually by using different sorting…
Farhan
  • 13
  • 5
-2
votes
1 answer

How to force java to draw swing label?

I am creating a progressBar using JLabel. Problem is when I add this label to my frame and execute some other tasks, my JFrame freezes. Is there any method like invoke and wait for swing to complete its drawing? private void…
hellzone
  • 5,393
  • 25
  • 82
  • 148
-2
votes
2 answers

Java GUI application

I am working on a Java graphical interface (Swing , AWT) . The data entry in my application is supposed to be done via a JFrame. In fact I have 10 entities that necessitate 10 JFrames. I used a for loop but JFrames don't seem to wait until data…
1 2 3
51
52