Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Frames  RSS feed

 
Patrick Mugabe
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a main screen (Main.java) which opens up Frame1.java when you click the OK button. The code I am using in the actionListener is
if(e.getSource() == OK)
{
new Frame1();
}

However, when I close Frame1, I would want to go back to the Main screen (Main.java). At the moment it closes both Frames when I close Frame1.java.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to be a little more specific. "When you close Frame1" how? Does Frame1 have a WindowEvent handler, or have you called setDefaultCloseOperation on it?
 
Patrick Mugabe
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am calling Exit class which has the following code:
import java.awt.*;
import java.awt.event.*;
public class Exit extends WindowAdapter
{
public void windowClosing(WindowEvent event)
{
//event.getWindow().setVisible(false);
System.exit(0);
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!