Dear Norm Radder, and other programmers,
Thank you for your recommendations. I have put the code below into code tags.I hope they are appropriate.
I will try describing the difficulty I am encountering with the code more clearly than I did before.
Because I (or anyone, presumably) can't write ClientGUI extends JFrame,
Thread - (though my Ivor Horton book says you can)
- I made two classes for ClientGUI - one holding the main method which instantiates and calls methods held within the other ClientGui program.
However there is the consequent problem in that ClientGUI holds an ActionListener/ Performed method - so it can't object.method() call from
the MainMethod class - ie: it can't invoke the sendmessage() method within it from the MainMethod, as the ActionPerformed is to press the
button 'SEND' which is in the GUI created by ClientGUI program.
The other methods like getConnection() can be object method called from within the MainMethod, as they are not contingent on an
ActionListener/Performed type method. If I copy the object.method() call process that invokes these methods in the MainMethod into the
ActionListener/Performed method in the clientGUI so that it might read :-
{
ClientGUI clientgui = new ClientGUI();
clientgui.sendMessage();
}
-then upon pressing the GUI's 'SEND' button I just get another GUI - from the instantiation, without the sendMessage() method ever being
reached, or executed.
Okay, maybe making two programs out of one wasn't such a cool idea after all, but then how do I extend one program from JPane (which I need
for the GUI) and Thread (which I need also to thread the sendMessage(), recieveMessage() methods?
I was thinking it'd be easier to get an idea of the problem if you just ran these programs, as writ, as they compile and run okay, they just
don't work (ie: take messages to the GUI'S textfield to and fro from Server and Client consoles, nor from GUI's textfield to textArea) like I
(or anyone) would wish them to. *****************************
**************************************************************************
***************************************************************************
***************************************************************************
As you may know, you have to run the Server program first, then the MainMethod to launch the ClientGUI program. I think the methods in ClientGUI are coded alright - to put input to text field to input and output streams and to transfer message thus initialised to the textArea.
Anyway thank you much for your help, particularly as most people out there are preoccupied with loot before they're prepared to offer any help.
Yours
Simon
[ July 26, 2008: Message edited by: Simon Evans ]
[ July 26, 2008: Message edited by: Simon Evans ]
[ July 26, 2008: Message edited by: Simon Evans ]
[ July 26, 2008: Message edited by: Simon Evans ]