File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes closing a current jframe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "closing a current jframe" Watch "closing a current jframe" New topic
Author

closing a current jframe

bijoy bose
Ranch Hand

Joined: Mar 27, 2004
Posts: 32
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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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 ]

[Jess in Action][AskingGoodQuestions]
bijoy bose
Ranch Hand

Joined: Mar 27, 2004
Posts: 32
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

Joined: Mar 27, 2004
Posts: 32
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

Joined: Mar 27, 2004
Posts: 32
please help.....its urgent
Bernhard Jung
Greenhorn

Joined: Sep 14, 2004
Posts: 11
How to Make Frames (Main Windows)


[ January 07, 2005: Message edited by: Bernhard Jung ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: closing a current jframe