my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes creating my own dialog box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "creating my own dialog box" Watch "creating my own dialog box" New topic

creating my own dialog box

Edmund Castermund
Ranch Hand

Joined: May 09, 2007
Posts: 99
i'm creating a simple window that allows the user to enter some text...the problem I'm having is that I want the rest of the application to wait until the user has entered the data before continuing to process data.

For example, I have a similar function in the app that uses a JFileChooser; in that case, the file chooser dialog apppears, when the user selects the files they want, an object is created and then methods are executed, but not until the user has selected the files. In the dialog I'm writing, that doesn't happen; the application keeps right on going before the user can enter the information the dialog; the object is created with a null value, and of course, screws up the processing I want to do.

When using the JFileChooser, I have an if block that says something like

but I'm having trouble replicating that for my own dialog....

here's the relevant code that creates the dialog...
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10826

What you need is a modal dialog.
Check out JOptionPane It provides various convenient showXXXDialog methods which you can use.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Edmund Castermund
Ranch Hand

Joined: May 09, 2007
Posts: 99
that did it...I made the window extend JDialog, and set modal to true
I agree. Here's the link:
subject: creating my own dialog box
It's not a secret anymore!