Threads

Hey,

Im having a few problems with my messenger, I have a few working classes but my problem now lies with how do I go about, once a connection is created do other classes get access to the connection?

Cheers

When you create a connection:

myConnection = new XMPPConnection();

you have a reference to that connection, its “myConnection”.

When you want that other classes use that connection you must pass the reference to it, that is, give “myConnection” as a variable of a custructor of a class or even a method of that class!

Ok,

Im still having problems …

My messenger is based around a JTabbedPane layout, with one JPanel called login which instatiates the XMPPconnection. However on moving to another Panel say for instance ‘‘inbox’’ the connection variable hasnt been updated (ie ‘‘myconnection’’)… and isnt connected.

any ideas on where im going wrong here?

Maybe you’'re accidentally creating multiple connections? One thing you can try is to turn on debugging mode – that will open up a Swing window for every connection made and log all the XML going back and forth. Check the documentation for instructions on enabling debugging.

Regards,

Matt

Eache time you instantiate a Panel, the panel has no information about your connection. The variable myConnection isn’'t global to the whole program! If you want that the panel knows the connection you must give a reference to him, for example as argument when you create it!