-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.2, 1.4.0
-
x86, sparc
-
solaris_9, windows_nt
Name: skT88420 Date: 06/11/99
Open a JOptionPane in front of a JDialog that has its cancel
button mapped to the escape key. When you click escape on the
JOptionPane, the dialog behind it will pick up the escape key
also.
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import java.text.*;
import java.beans.*;
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.dnd.*;
import java.awt.event.*;
import java.sql.*;
public class msgboxbug
{
public static void main(String[] args)
{
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(null);
frame.setBounds(20,20, 750, 500);
final JButton button = new JButton("CLICK");
button.setBounds(0,0,100, 100);
frame.getContentPane().add(button);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
final JDialog d = new JDialog(frame, true);
d.getContentPane().setLayout(null);
final JButton button2 = new JButton("CLICK");
d.setBounds(50, 50, 200, 200);
final JButton buttonClose = new JButton("CLOSE");
button2.setBounds(0,0,150, 50);
d.getContentPane().add(button2);
button2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
final String[] sButtons = { "OK" };
JOptionPane.showOptionDialog(frame, "Click escape and dialog closes too and it shouldn't", "TEST",
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null, sButtons, sButtons[0]);
}
});
ActionListener l = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
d.setVisible(false);
d.dispose();
}
};
buttonClose.addActionListener(l);
buttonClose.setBounds(0,50,150, 50);
d.getContentPane().add(buttonClose);
buttonClose.registerKeyboardAction(l, "EscapeKey",
KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE,
0 , true),
JComponent.WHEN_IN_FOCUSED_WINDOW);
d.setVisible(true);
}
});
frame.setVisible(true);
}
}
(Review ID: 84248)
======================================================================
Name: skT88420 Date: 06/11/99
I have a JOptionPane message box over a JDialog (the dialog
maps the escape key to a cancel button). When the escape key
is pressed when the JOptionPane is up, the JOptionPane is
closed and the JDialog behind it is closed. The JDialog should
not get that escape key event.
(Review ID: 84213)
======================================================================
- relates to
-
JDK-5047331 Esc key makes ControlPanel exit on Linux
-
- Closed
-
-
JDK-4088881 ActionEvent not being properly consumed ...
-
- Closed
-