Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

closing a current jframe

 
bijoy bose
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone know how to close a current oppened window/Jframe

class hello extends JFrame
{
private Jbutton btnExit = new JButton("Exit");
private Container cp1 = getContentPane();
//.....
Public hello()
{
Super("closing current window");
//.......

btnExit.addActionListener(new Close());
//
cp1.add(btnExit);
}
public class close implements ActionListener
{
hello hell = new hello();
public actionPerformed(ActionEvent ae)
{
String nme = ae.getActionCommand();
if(nme.equals("Exit"))
{
//TEL ME WHAT GOES HERE to close the current window "Hello"
hell.SetVisible(false); //will this work???
}
}
}
}
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setVisible(false) will hide it, but it will still exist. dispose() free the resources and do whatever the close action is set up to do -- hide by default, but can also exit the app if you want.

But this isn't Advanced Java -- it's a basic Swing/AWT question. I'm going to move this to the Swing/AWT forum for further discussion.
[ January 06, 2005: Message edited by: Ernest Friedman-Hill ]
 
bijoy bose
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the frame doesn't closes...even, i checked the code and found that the control is going in the if's "Exit" block....please help!
 
bijoy bose
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i might sound little confusing...but frame that i am closing is currently onfocus and what i want is that when i press the Exit button the frame should disapear...
 
bijoy bose
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help.....its urgent
 
Bernhard Jung
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to Make Frames (Main Windows)


[ January 07, 2005: Message edited by: Bernhard Jung ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic