-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
x86
-
windows_nt
Name: boT120536 Date: 12/14/2000
JDK 1.3 final release for Windows
Try the following test class.
1) Set the focus into the TextField und press the button (hold down the mouse
button for a second) or use the Mnemonic. The ActionEvent apears before the
OptionPane opens. I think this is wrong. Move the mouse above the Button
and it will be painted pressed if the mouse is above the button (wrong, too).
2) Start the test and set the focus into the TextField, again. Move the mouse
above the Button and press the mouse button very short (just a short klick).
No ActionEvent apears (not before and not after the OptionDialog).
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class Dialog implements FocusListener, ActionListener {
public static void main(String[] args) {
JFrame frame = new JFrame("OptionPane in FocusLost");
JTextField textField = new JTextField("Halilalo");
textField.addFocusListener(new Dialog());
JButton button = new JButton("Button");
button.addActionListener(new Dialog());
button.setMnemonic('B');
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(textField);
frame.getContentPane().add(button);
frame.pack();
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
System.out.println("actionPerformed");
}
public void focusLost(FocusEvent e) {
// System.out.println(e);
System.out.println("focusLost "+e.isTemporary());
if (!e.isTemporary()) {
System.out.println("showMessageDialog");
JOptionPane.showMessageDialog(null, "Hallo");
}
}
public void focusGained(FocusEvent e) {
// System.out.println(e);
}
}
(Review ID: 107250)
======================================================================
- duplicates
-
JDK-4368790 JButton stays pressed when focus stolen
-
- Resolved
-