wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes Interacting with dispatch thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Interacting with dispatch thread" Watch "Interacting with dispatch thread" New topic

Interacting with dispatch thread

George Burton

Joined: Aug 18, 2009
Posts: 1
Hi guys,

I am developing an app that has 2 different GUIs but having difficulties passing data from the initiliaser threads to the GUIs.

The 1st GUI (MessageDisplay) is initiliased by a thread on receipt of a UDP packet:

The 2nd GUI is then created on click of a button on the 1st GUI:

in MessageDisplay.java:

The 2nd GUI is then initialised by invoking an 'initComponents()' method on the event dispatch thread in its run() method:

I then need to update the 2nd GUI from another method in the ChatSession.java object which is listening for TCP packets. I have a JTextArea on the 2nd GUI called 'conversation' to which I need to append any new text that comes in over the TCP socket.

How can I do this? I have tried using invokeLater to run a method on the event dispatch thread, but I get a NullPointerException error...???

I also need to pass data from the event dispatch thread to the ChatSession object on click of a button (in order to send it over the network to another client).

I have a metohd in ChatSession.java which is assigned to respond to clicks of the button using an Action Listener initialised on the event dispatch thread:

The method in ChatSession.java:

.... is assigned to an ActionListener in initComponents() , part of ChatSession.java, (which is run on the event dispatch thread, see earlier):

Basically, how do I pass data from the event dispatch thread to the 'initialiser' object, and then how do I pass data from the initialiser back to the event dispatch?

Can anyone give me some hints?
I agree. Here's the link: http://aspose.com/file-tools
subject: Interacting with dispatch thread
It's not a secret anymore!