• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Interacting with dispatch thread

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic