This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How prevent the user closing the Joptionpane by clicking the X in the right end corner

 
Vinod Joseph
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The requirement is if the user clicks the X in JOptionpane it should not close.

In JDialog we have setDefaultCloseOperation but i am not sure what is the functionality that we have to implement in JoptionPane similar to the setDefaultCloseOperation.

optionsConfirm[0] = new String(EJbundle.getString("YES"));
optionsConfirm[1] = new String(EJbundle.getString("NO"));
int answer = JOptionPane.showOptionDialog()

if (answer== JOptionPane.YES_OPTION) { }

if (answer == JOptionPane.CLOSED_OPTION) { If the user click the X button of the JOPTIONPANE it should not close. I know that setdefaultclose operation was in JDialog. But i am not sure how the same/alternative can be implemented in JOptionPane }

Thanks in advance.
 
Rob Camick
Ranch Hand
Posts: 2534
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quit cross posting: http://www.java-forums.org/awt-swing/47524-prevent-user-close-joptionpane-using-x-button.html

Instead learn how to use one forum properly, for example, by learning how to post code properly so it is readable.

In JDialog we have setDefaultCloseOperation but i dont what can be done in JoptionPane.


Read the JOptionPane API. It shows you how to access the dialog used by the option pane.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please remember Rob Camick's advice.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic