Home arrow static arrow Java Programming [Archive] - Help with GUI forms
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Help with GUI forms
This topic has 5 replies on 1 page.

Posts:2
Registered: 10/2/03
Help with GUI forms  
Jun 14, 2004 6:09 AM



 
Hello, I'm creating a java IM program and need some help. I have it to the point where the user can double-click on one of the names in the Buddy List and it opens up a new GUI window for the chatting. However, when the chatting window is closed, the whole client program closes.

The base class is called Client. This class creates a new ClientGUI(the buddy list), which when the user double-clicks on a name opens up ClientIM(the chatting window). The ClientIM is opened in another thread (I thought it would fix it, but it didn't). Please help with any suggestions.

Client:
g = new ClientGUI();
g.setTitle(name);
g.show();

ClientGUI:
Thread t = new Thread(){
public void run(){
c = new ClientIM();
c.show();
windowMap.put(lstBuddies.getSelectedValue(),c);
}
};
t.start();
 

Posts:951
Registered: 6/7/01
Re: Help with GUI forms  
Jun 14, 2004 6:18 AM (reply 1 of 5)



 
What type of container are you using for the chat (JFrame, JWindow etc)? And do you have any window listeners added to this component?
 

Posts:5,627
Registered: 3/22/04
Re: Help with GUI forms  
Jun 14, 2004 6:22 AM (reply 2 of 5)



 
First, the indiscriminate use of threads often leads to more problems. Second, I don't believe you posted an appropriate piece of code.

Maybe (without a whole lot of information) you want to do something like this (pseudocode):

1. Get selected name
2. Open a custom dialog with name passed in as parameter
3. Look up name in list of IP addresses
4. Create connection to address
5. Chat
6. Close connection
7. Close dialog

Good luck.
 

Posts:49
Registered: 2/5/04
Re: Help with GUI forms  
Jun 14, 2004 6:39 AM (reply 3 of 5)



 
U might be using System.exit(0) for closing up the client.
Is it so. In that case the whole thing will go of. Instead use setDefaultCloseOperation() of JFrame for closing that window only

Hope this helps
Karthik
 

Posts:2
Registered: 10/2/03
Re: Help with GUI forms  
Jun 14, 2004 11:19 AM (reply 4 of 5)



 
I feel like a *****. I'm using NetBeans IDE to design the GUI for the first time. I never even thought it would assign the default window closing event to exit. :'(

Oh well, thanks for the replies, its working great now.

-Steven Cohen
 

Posts:5,627
Registered: 3/22/04
Re: Help with GUI forms  
Jun 14, 2004 11:29 AM (reply 5 of 5)



 
This is one of the biggest reasons NOT to use an IDE. GUIs should be developed by hand.
 
This topic has 5 replies on 1 page.