• 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

Parent and child window cncept in java swing

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had created a window based desktop application using java Swing. I used jDesktopPane for it. my problem is that when clicking a button in a parent window, a child window is opened, it asks for input, i want before the input is not given in the child window,one cannot close the parent window. just like in MS-word, when we open a font dialog box, until unless we are not done with the dialog box, we cannot close the word window.we have to first close that dialog box and then only we can close the main window of MS-word. Please Help me with some relevant examples and code.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using a JInternalFrame for this "child window" you are out of luck. What i suspect you want to do is open a modal JDialog instance of some sort to accept the input then pass this back to the parent, which would then open the JInternalFrame child. There are many dialogs you can use using the JOptionPane and it's static methods. Or you can create your own subclass of JDialog.

http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html
 
Amardeep Shah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sir i have used Jdesktoppane to create the main window and then i have used jInternalFrame to make other sub-windows and added it to jDesktopPane whenever it is called on the occurenec of any event in the main window.the problem is that if i close the main window at this time, it closes, i want it not to exit until unless all the sub windows are not closed.i want that it should prohibit me to close the main windows until unless any of the sub window is opened.


Thanks
with regards
Amardeep Shah
 
Sheriff
Posts: 22781
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
Set the default close operation to WindowConstants.DO_NOTHING_ON_CLOSE, then add a WindowListener:
 
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic