• 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

JDesktopPane

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Is it possible to add a window listener to JDesktop so I can give and option to close the window so the program is not closed by mistake.

Thanks
Mike
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's JDesktop? There's no such class in the standard API
 
Michael Alan Brown
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, thanks for responding, I mean JDesktopPane.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And by JDesktopPane, I'm sure you mean JInternalFrame

See what methods the latter has? Most notably one that starts with "add" and ends with "Listener"? It's the closing event that will be triggered just before it is actually closed. Don't forget to set the right default close operation (hint hint hint); the default is no longer the one you want.
 
Michael Alan Brown
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help but I still a bit stuck.

What I am trying to do is close the window that contains all the internal frames not the internal frames. This will let me put up a message before all the frames are closed.

Sorry, if this is really obvious.


Mike
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,
Please read http://faq.javaranch.com/java/UseAMeaningfulSubjectLine

You can edit the title by clicking on the button
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The window with the JDesktopPane in it is probably a JFrame and JDialog. My advice basically still holds, only you will use a WindowListener instead of an InternalFrameListener, using the windowClosing event. You still need to set the proper default close operation.
 
Michael Alan Brown
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all you responses but I still having the problem. Even when I set the close option to do nothing the window still closes and I can not add an internal frame or window listener


 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JFrame extends Window so it has method addWindowListener. I don't see you calling it anywhere.
 
Michael Alan Brown
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all the help. I don't know what the problem was but eclipse is now letting me add the listener.

Thanks
Michael
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic