Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

JOptionPane behavior  RSS feed

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would think you would want something like:

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

Where parentComponent is your other dialog.

-Tad
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
ScroogeXHTML 8.0 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/704747/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!