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 NetBeans IDE 5.5 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 "NetBeans IDE 5.5" Watch "NetBeans IDE 5.5" New topic
Author

NetBeans IDE 5.5

vijayalaxmi amu
Greenhorn

Joined: Nov 22, 2007
Posts: 8
hi.
how can i close 1st jframe with a click of mouse?and open next jframe?
Hanuma Deepak Muvvala
Ranch Hand

Joined: Nov 20, 2005
Posts: 158
which JFrame?
vijayalaxmi amu
Greenhorn

Joined: Nov 22, 2007
Posts: 8
How can i open 2nd frame in the same project by a click of a button in 1st frame? and close 1st frame?
pleas help
thank you
Nidhi Nagre
Ranch Hand

Joined: Nov 05, 2007
Posts: 64
just take a reference of second jframe and make its setVisible property true inside event handler and also make setVisible property of first jframe to false immediatly after.

cheers
vijayalaxmi amu
Greenhorn

Joined: Nov 22, 2007
Posts: 8
thanks nidhi,
i did that but i can open 2nd frame but 1st frame will be there at back.
any other solutions?
thank you
John Mclain
Ranch Hand

Joined: Nov 04, 2007
Posts: 30

vijalaxmi wrote:
i did that but i can open 2nd frame but 1st frame will be there at back.
any other solutions?



prefer it,
JFrame yourframe=new JFrame();
yourframe.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowLostFocus(WindowEvent e) {
super.windowLostFocus(e);

yourframe.setVisible(false);
}

});


hope this will help you

cheers
vijayalaxmi amu
Greenhorn

Joined: Nov 22, 2007
Posts: 8
thank you john
the last line is giving error that is yourframe.setVisible(false);
if i remove this line and run the frame its not closing the 1st frame.
thank you.
John Mclain
Ranch Hand

Joined: Nov 04, 2007
Posts: 30
I am in little difficulty to understand, what exactly you are doing.
can you phrase your code here?
vijayalaxmi amu
Greenhorn

Joined: Nov 22, 2007
Posts: 8
JFrame mainpage = new JFrame();
mainpage.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowLostFocus(WindowEvent e) {
super.windowLostFocus(e);
mainpage.setVisible(false);

mainpage.setVisible(false); is error.

rest of the code is no problem.
if i run without the last line of code frame is opening but will not close the 1st frame.
thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NetBeans IDE 5.5
 
Similar Threads
title
why no default close button in JDialog
how to invoke FileDialog from a dialog?
How to display JFrame with orientation Right_To_Left in Windows 7 64bit..?
painting problems