File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Opening a new window. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Opening a new window." Watch "Opening a new window." New topic

Opening a new window.

Ian Locke

Joined: Feb 26, 2009
Posts: 5
Hi everyone

Im trying to get a new window to open once I click the Add Customer button in my first window, but I have no idea how to do it. Could someone point me in the right direction?


Here's my code so far:

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

A new "window"? Would that be a JDialog or a JFrame? You already know how to open a new JFrame, in fact you posted an example of that here. But you might well be better served by a JDialog to allow entry of customer information.
Ian Locke

Joined: Feb 26, 2009
Posts: 5
I want it to be another JFrame but I cant get 2 JFrame's to work. When I click the button I need to enter the customers info and have some buttons to select what I want to do with this info.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
the text of each button indicates the screen's of your other frames might be detailed.

if so, using a CardLayout() might be a good soution:
build each screen via a JPanel
add each panel to a cardLayoutPanel
add the cardLayoutPanel to a frame

each button's actionPerformed simply shows the relative screen
Ian Locke

Joined: Feb 26, 2009
Posts: 5
Ok nice one

Thanks for the help
I agree. Here's the link:
subject: Opening a new window.
It's not a secret anymore!