This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

creating my own dialog box

Edmund Castermund
Ranch Hand

Joined: May 09, 2007
Posts: 85
Hi,
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: 10425
    
    8

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: 85
that did it...I made the window extend JDialog, and set modal to true
 
GeeCON Prague 2014
 
subject: creating my own dialog box