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

Using multiple voids in Java

In the past few months I've tried my hand at programming in Java, and for the most part haven't had any problems with it, but right now I'm having some trouble working with voids. In my program the user presses a button and the goal is for multiple…
KrisC
  • 57
  • 4
0
votes
1 answer

Can't update GridPane

I have a simple app with a grid (GridPane) and a simple toolbar with Start/Stop buttons. My buttons action looks like this: startButton.setOnAction(new EventHandler() { @Override public void handle(ActionEvent…
4lex1v
  • 21,367
  • 6
  • 52
  • 86
0
votes
1 answer

ProgressBar when program is running

I'm trying to add to my program progress bar ,when it executes.Actualy I want to add something like this: public class TestProgressBar extends javax.swing.JFrame { public TestProgressBar Bar; public TestProgressBar() { …
babkamen
  • 3
  • 1
  • 2
0
votes
3 answers

Open card after certain time

i'm programming a blackjack (single thread) for a university project and the dealer is the computer (e.g. no player action)... Does someone know how can I program in Java something like this: while (dealerpoints < 17) open card and repaint…
Gabriel Sotero
  • 155
  • 1
  • 13
0
votes
1 answer

Getting Amazing Exception with Threading In Java Swing

I am getting the following amazing exception when I am using multi-threading in my code but, I can not figure out where it occurs. Also this exception occurs only sometimes. Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException:…
0
votes
1 answer

Problems in running I/O in EDT of applet

Our applet source code is kind of spaghetti (written in 2000, Java 1.3 then) and we want to recompile it to Java 1.6 or 1.7. When I'm testing it, most of the Swing is OK but after sometime, an Exception occurred, which is EDT exception. …
ton
  • 355
  • 3
  • 13
0
votes
1 answer

Dispatching events into right thread

I have developed a wrapper for a library that uses a callback to notify events. This callback is called using another thread than UI's thread, so the wrapper uses the following script to call the event handlers into the right thread for a WinForm…
Jairo
  • 876
  • 7
  • 14
0
votes
1 answer

Why does Potochkin's EDT checker flag this code?

I don't understand why my code is getting flagged in this one instance. myPlot.plot(serviceRef, frameMax, frameMin); That line is the source location of the error. It does not make any sesne to me since there is no Swing code in the line of code.…
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
0
votes
2 answers

Java basic GUI program receiving this error "AWT-EventQueue-0" java.lang.NullPointerException"

I am trying to build a simple gui program. Everything worked well because I tested the classes before adding some GUI components such as in SWING and AWT. However when I tried some input and press the submit button it gives me this error. Exception…
dimas
  • 2,487
  • 6
  • 40
  • 66
0
votes
1 answer

using double buffering kinda ruin my applet. and it has java uses or overrides a deprecated API

this is my code actually it's just a moving space invader game. i search the internet for the animation i have tried the double buffering, it gets rid the flickering but its ruining the entire output. it also has java uses or overrides a deprecated…
0
votes
1 answer

add 2 objects to JFrame on a specific location

This is my class that creates a circle shape with specific x and y coordinates. Similarly I have another same class but with different x and y coordinate positions. I create 1 object of each class and want to display them on specific positions on…
0
votes
1 answer

How to show processing info. in program?

I have created a GUI having one JButton and some other components. When I click the button, some back end processing is involved which takes nearly 10-12seconds. How should I represent it graphically?
svkvvenky
  • 1,122
  • 1
  • 15
  • 21
0
votes
1 answer

automatic update jtextfield

Does anyone know how to update a jTextfield every 5 secondes? Automatic. So no userinput is required. It is used to update time in a textfield. This is what i tried but then my program freezes. while(true){ …
Pim_D
  • 89
  • 1
  • 10
0
votes
3 answers

Show progress during FTP file upload in a java applet

OK so I have the uploader uploading files using the Java FTP, I would like to update the label and the progress bar. Label with the percent text, bar with the percent int value. Right now with the current code only get the 100 and full bar at the…
user1634307
  • 5
  • 1
  • 5
0
votes
1 answer

Does JGoodies binding take up too much time on the EDT?

I am using JGoodies binding for my swing components. I have a demanding realy time display in my program that won't update visually when JGoodies binding is turned on. Is there a way to have the binding not hog the EDT thread?
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113