Re: Swing App question
"Java and Swing" <codecraig@gmail.com> wrote in message
news:1159983324.798584.123070@i42g2000cwa.googlegroups.com...
Oliver Wong wrote:
Traditionally, you have one message/log panel per buddy, so that's
one
way to avoid this whole problem.
well the client model keeps a map of buddys that connect. when a new
message is sent in from a buddy, a new ChatPanel is created for that
conversation. currently I am passing client model around...which i
don't like...hence what I am trying to figure out.
So perhaps the MainPanel should fire a "Open Chat" event, so a new chat
panel opens up...
Yes, this is what I meant by one message/log panel per buddy.
and the model stores this information. The
ClientModel stores Buddy objects....so shoudl the buddy objects store
"chatOpen = true/false"?
I'm assuming you're making an instant messaging client. I'd have the
each buddy window registered with a main window (where the buddy list
appears), and the main window registered to the model, and the model is
registered to whatever it is that's handling the networking stuff. When a
packet comes in, the a signal is sent to the model to translate it into an
application level event, such as a new message coming from a specific buddy.
The model updates itself with this info, and notifies all of its listeners.
One such listener is the main window. The main window checks its list of
listeners to find out if there's already a window associated with that
buddy. If so, it notifies that window of the event. Otherwise, it creates a
window associate with the buddy, and immediately notifies it.
- Oliver