• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

close button

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I program a button for closing down the applet? I always thought it was closed manually by the user clicking on the mouse, but I am supposed to write an applet that uses a "close" button to close down.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well there is more than one way to do this.
If you were going to use the X in the corner you would either create a class and extend WindowAdapter, or implement WindowListener.
However, since you need a button to do this, you need to create a class to implement something that Button listens to. One of the things that Button listens to is an ActionListener. (You can check this by looking in the API and checking what addXXXListener methods the component has).

Now you have to create a gui and on that qui you need to make a button. When you have your button, you need to create an instance of your listener, and then hook the two together.

Now all you need is to get this in an Applet or a Frame, and all should be good.
 
Jade Davidson
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic