• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

MODAL JFRAME

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello good wishers,
Does someone know how can we make a JFrame( or its subclass) a modal. For those who do not know what modal is: Modal means only dialog/frame can be worked with while it is active. To work with other windows for same application running, current window must be closed.
What I tried to do is, I created a class extending javax.swing.JFrame, after which in the main method, I created JDialog passing new JDialog(this, true). this means the frmae to be modaled and true means make this frame modal.
But executing this program will cause just a small frame with nothing in it, whereas I would expect all the components, as I would expect with frame.setVisible(true).
I don't know why and how to resolve this. Please let me know ASAP.
Thanks all in advance.
Nilesh
 
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
You can make a frame modal to the application by using a JDialog instead of JFrame. However, you can't make a frame model to the computer using just java... you'd have to use JNI or something to evoke system code...

It sounds like you got messed up using the JDialog... the way to fix your code would be to move all the components on your frame onto the dialog you create... in the JDialog( Frame, boolean ) constructor, the Frame indicates the parent of the dialog you are creating, and whether the new dialog itself is modal or not...

-Nate
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic