I have a JOptionPane whose buttons are not respond quite right. Lets say I hit No the next time the JOptionPane comes up again I cannot hit on No again but I can hit on either Yes or Cancel. And the same problem happens with the other buttons. If I no hit Yes the next time around I cannot hit on Yes again
final JOptionPane optionPane = new JOptionPane(
"The xxxxx has changed.\n Do you want to save the changes?",
JOptionPane.QUESTION_MESSAGE,
JOptionPane.YES_NO_CANCEL_OPTION);
dialog = new JDialog(frame,true);
dialog.setFont(font);
dialog.setContentPane(optionPane);
optionPane.addPropertyChangeListener(
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e)
{
String prop = e.getPropertyName();
System.out.println("propertyChange " + prop);
if(dialog.isVisible() && (e.getSource() == optionPane)
&& (prop.equals(JOptionPane.VALUE_PROPERTY) ||
prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
if(optionPane.getValue() instanceof Integer)
{
int value = ((Integer)optionPane.getValue()).intValue();
if (value == JOptionPane.YES_OPTION)
{
....
}
else if (value == JOptionPane.NO_OPTION)
{
....
}
else if(value == JOptionPane.CANCEL_OPTION)
{
....
}
}
else
dialog.setVisible(false);
}
}
});
dialog.pack();
dialog.setLocationRelativeTo(frame);
Thank you
[ June 21, 2005: Message edited by: john mattucci ]