Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Can I Make JFrame modal?

 
Ramses Tutoli
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to pop up a screen when a user starts up the app but no suncertify.properties file exists, or the file doesn't contain the necessary property. But to do this I need the pop up to be modal.
I know that JDialogs can be modal, but they aren't top-level containers (or are they?). Anyways, the constructors for JDialogs all seem to take a parent container as an input parameter, so I don't know if I can use it the way I want. I looked at JOptionPane, but I can't use that because it doesn't allow me to add components, and I want to add a JFileChooser to my pop up for choosing the database path.
thanks.
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramses,
You can use the JDialog(Frame owner) with owner==null to popup your modal dialog (when all else fails, read the Javadoc). I use my own custom dialog for server and client modes and simply use a JFileChooser for standalone mode before the main window is ever displayed.
BTW, some bartender will probably warn you soon about the JavaRanch naming policy. Please comply.
kktec
SCJP1.4 & SCWCD
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11888
203
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramses,
Welcome to JavaRanch.
We don't have many rules here, but one we do have is our naming policy. We do require you to have both a first and last name in your displayed name, although you may use an initial for the first name if you really want to. You can change your displayed name here.
Thanks,
Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic