File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JOptionPane behavior Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JOptionPane behavior" Watch "JOptionPane behavior" New topic
Author

JOptionPane behavior

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
I have not used swing in a while so im not sure if this the proper behavior.

dialog = new JDialog(this, "ERROR", true);
JOptionPane optionPane = new JOptionPane("The xxxxx name cannot be blank.",
JOptionPane.ERROR_MESSAGE);
dialog.setContentPane(optionPane);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.setResizable(false);

I have a JDialog box which has some mandatory fields and if those fields are not filled this JDialog appears. My problem is that if I click on the X for the message dialog both itself and its parent JDialog are closed. Is this normal? And second I have an ok button in the message jdialog which when clicked on does not respond. I didnt think that I had to implement a listener for this button.

Thank you all for your help
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I would think you would want something like:

JOptionPane.showMessageDialog(parentComponent, "you left xxx blank");

Where parentComponent is your other dialog.

-Tad
 
Consider Paul's rocket mass heater.
 
subject: JOptionPane behavior