• 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

mouseClicked event for the "Cancel button"

 
Ranch Hand
Posts: 70
Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to write the mouseClicked event for the "Cancel button" where the entire window has to close on pressing the Cancel button. I wrote the following code:

But, when I run this code, only the contents of the window get erased and the window remains unclosed. Please let me know what has to be written between lines 104 and 110.
 
Ranch Hand
Posts: 160
IntelliJ IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at line 108. You want to close the frame, but all you do is to make the components on your frame invisible. You need to dispose of the frame.

Something like this.


The PmtGui.this is used to tell your anonymous inner class (MouseAdapter) that you are referring to the outer class (PmtGui).

On a side note, don't use MouseListeners on buttons. If you disable the button, the MouseListener will still register events. Rather use an ActionListener.
 
Shikha Upadhyaya
Ranch Hand
Posts: 70
Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Riaan Nel wrote:Look at line 108. You want to close the frame, but all you do is to make the components on your frame invisible. You need to dispose of the frame.

Something like this.


The PmtGui.this is used to tell your anonymous inner class (MouseAdapter) that you are referring to the outer class (PmtGui).

On a side note, don't use MouseListeners on buttons. If you disable the button, the MouseListener will still register events. Rather use an ActionListener.


Ok. Thanks It's working now
 
reply
    Bookmark Topic Watch Topic
  • New Topic