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 Display a new frame by hiding the existing frame 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 "Display a new frame by hiding the existing frame" Watch "Display a new frame by hiding the existing frame" New topic
Author

Display a new frame by hiding the existing frame

Karthick Hbk
Greenhorn

Joined: Sep 14, 2012
Posts: 1
Hi, This is my first post in javaRanch, Hope I vl get my solution. Let me share the issue, What i had.

I am doing a project completely based on swing components. In that In the topleft corner of the frame, There will be a new, save and open buttons for their respective functions. If the user clicks the Save button after enter the inputs & If the same user clicks a new button means, It should create a new frame that contains a fresh application page that should not contain, What user entered before clicking new button. The challenging thing is that, When user clicks new button, The new frame should appear by hiding the existing frame.

I don't know how to achieve this using swings.
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

It's not a good approach to show multiple JFrame instances in one application. Instead, you can as well use dialogs or internal frames (inside the main application frame). You should check this tutorial:
To make a window that is dependent on another window — disappearing when the other window is iconified, for example — use a dialog instead of frame.. To make a window that appears within another window, use an internal frame.


The quieter you are, the more you are able to hear.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> It should create a new frame that contains a fresh application page that should not contain, What user entered before clicking new button.

if the original application page is identical to the application page after clicking the new button,
all the new button has to do is to clear/reset all the input fields/comboBoxes etc.

if the aplication pages are different, perhaps a CardLayout might suit, but you'd still need to
clear a page if the new button is clicked more than once.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Display a new frame by hiding the existing frame
 
Similar Threads
FileDialog
how to pass data from one frame to other
Button enabled property not refreshing on the panel
disposing SAVE file dialog its urgent
Wicket Framework - not able to get return value back from confirmation dialog