Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To quit window by button

 
Vipul Tangri
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to quit my frame by button ...
how could i do it?
one more thing, how i donno allow to resize my frame ?ie no maximisation
thx,
vipul
 
Paul Stevens
Ranch Hand
Posts: 2823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use the hide() method. If you no longer need to use it again, use dispose(). Both are in the Window class.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make your frame non-resizable, use:


Are you trying to close your window with the X button up in the corner, or with a java button on the GUI? If you want to close with the X button you have to add a WindowListener to the window that overrides the windowClosing() method. If you are using another button you have to add an ActionListener to that button.

-Nate
 
Vipul Tangri
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nathan Pruett:
[B]To make your frame non-resizable, use:


Are you trying to close your window with the X button up in the corner, or with a java button on the GUI? If you want to close with the X button you have to add a WindowListener to the window that overrides the windowClosing() method. If you are using another button you have to add an ActionListener to that button.

-Nate[/B]

hi Nathan,
i tried to close my GUI with the help of a button and i add a windowlistener to that button.
i wrote
public void actionPerformed(ActionEvent e)
{
if e.getSource()==button // button i want to use to close
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
}
but itdidn't work...
 
Paul Stevens
Ranch Hand
Posts: 2823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what happened when you used hide() or dispose()?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


or:



-Nate
 
Vipul Tangri
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx Nate and Stevens....
the button problem is solved as well as resize one...
thx once again..
vipul
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic