This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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:
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?