GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JDialog Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JDialog Question" Watch "JDialog Question" New topic
Author

JDialog Question

Donald Wedding
Ranch Hand

Joined: Aug 28, 2001
Posts: 72
I want to use swing GUI components to have the user enter the IP address and PORT address if they are in server mode.
I want to do this with TWO different "JTextField".
Basically, I want a popup box that is MODAL. I want the user to fill in the two fields and hit OK or else hit CANCEL. I don't want the user to be able to do anything else until he has filled in those fields.
I don't think I can use the JOptionPane for this since I want two JTextFields (can I?)
When I use a JDialog box, that works find except that it isn't modal. When I use the command:
jdialog.setModal( true );
it has no effect.
When I pass it a "true" in the constructor, it makes the JDialog modal, but it puts it behind my JFrame, so my whole program freezes.
What can I use?
emil dragan
Greenhorn

Joined: Dec 11, 2001
Posts: 10
Donald,
I didn't have the kind of problem you're describing with the JDialog. I have a class that extends JDialog and it makes the following call in the constructor:
super(parent, "Book flight", true);
parent - is the application frame (JFrame)
true - specifies that the dialog should be modal
Hope this helps!
Donald Wedding
Ranch Hand

Joined: Aug 28, 2001
Posts: 72
Thanks for the info. So exactly how do you call your extended JDialog class? What you describe is not much different from what I am doing. I am hitting my head against the wall with JDialog.
I can't find any good info on the web!
emil dragan
Greenhorn

Joined: Dec 11, 2001
Posts: 10
See code below:
class ActionHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "Book Flight") {
new BookFlightDialog(parent, data).show();
}
else if (e.getActionCommand() == "Close") {
data.close();
System.exit(0);
}
}
}
BookFlightDialog class extends JDialog and contains the following statement in its constructor:
super(parent, "Book flight", true);

Hope this helps!
emil
 
GeeCON Prague 2014
 
subject: JDialog Question