This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Pressing a button to open a new window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Pressing a button to open a new window" Watch "Pressing a button to open a new window" New topic
Author

Pressing a button to open a new window

Ilh Oleo
Ranch Hand

Joined: Feb 07, 2007
Posts: 57
Hi i�m developing an application about a repair shop for automotive vehicles with a connection to a DB.
Waht i want to do is this :i have my button "New Client" and i�m trying to do that when i press the button , it opens a new window (i think it would be a new JFrame) where it will be the application form to fill it with the name,last name, address, telephone and so on but i don�t know what component i have to use.
matt eggbeers
Greenhorn

Joined: Mar 11, 2005
Posts: 14
You could use either a JFrame or a JInternalFrame.
Ilh Oleo
Ranch Hand

Joined: Feb 07, 2007
Posts: 57
but how can i implement it??
what kind of method can i sue to open a window when i do click with the mouse over the button?? that is what i want to know
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
usually a JDialog is used, similar to a JFrame, but used modally,
meaning execution of the calling method is paused until the dialog closes,
and, if it's the way you want to do it, return the input data.
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 688

Have you...

1) ...created and added a listener for your button?
2) ...created your new client window by using the new operator?
3) ...set your layout manager for your client window?
4) ...added the components to your new client window?
5) ...called setVisible(true) for your new client window? Do this last of all.
6) ...are you using more than a single thread? this requires extra care.

Kaydell
Ilh Oleo
Ranch Hand

Joined: Feb 07, 2007
Posts: 57
I have this

........more code above....



And this is what it should appear at clicking the button



But nothing appears, by the way it�s OK to post all that rude code? (i mean the part of the init components)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pressing a button to open a new window
 
Similar Threads
How can i add a child window on an existing window
javascript closing windows
How to add a new window on existing one
using current window info in new window
Get information from JFrame