• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To quit window by button

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what happened when you used hide() or dispose()?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


or:



-Nate
 
Vipul Tangri
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thx Nate and Stevens....
the button problem is solved as well as resize one...
thx once again..
vipul
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic