-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.2, 6
-
x86
-
windows_2000, windows_xp
FULL PRODUCT VERSION :
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 ( build 5.00.2195 ) Service Pack 4
A DESCRIPTION OF THE PROBLEM :
When a component lost it focus and at focusLost() you show a JOptionPane.showMessage(), calling requestFocus of the same component that lost it causes a second call to focusLost().
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
When focus goes to text2, shows a message, then when finish to show the message, text1 request focus, and then focusEvent is callend again( no idea by what )
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Do not call two times the focusEvent when forcing the focus on the component that fires focusEvent.
ACTUAL -
Calls focusEvent once again after requestFocus() on the same component after displays a modal JDialog
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FocusTest {
public static void main(String[] args) {
JFrame frame = new JFrame("Focus test");
final JTextField field1 = new JTextField("Test1");
final JTextField field2 = new JTextField("Test2");
field1.addFocusListener(new FocusAdapter(){
public void focusGained(FocusEvent e){}
public void focusLost(FocusEvent e){
if( !e.isTemporary() ){
JOptionPane.showMessageDialog(null, "Focus lost in 1");
field1.requestFocus(); //- This makes the focus to be called again
}
}
});
frame.getContentPane().add(field1, BorderLayout.WEST);
frame.getContentPane().add(field2, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setBounds(0,0,200,300);
frame.show();
}
}
---------- END SOURCE ----------
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 ( build 5.00.2195 ) Service Pack 4
A DESCRIPTION OF THE PROBLEM :
When a component lost it focus and at focusLost() you show a JOptionPane.showMessage(), calling requestFocus of the same component that lost it causes a second call to focusLost().
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
When focus goes to text2, shows a message, then when finish to show the message, text1 request focus, and then focusEvent is callend again( no idea by what )
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Do not call two times the focusEvent when forcing the focus on the component that fires focusEvent.
ACTUAL -
Calls focusEvent once again after requestFocus() on the same component after displays a modal JDialog
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FocusTest {
public static void main(String[] args) {
JFrame frame = new JFrame("Focus test");
final JTextField field1 = new JTextField("Test1");
final JTextField field2 = new JTextField("Test2");
field1.addFocusListener(new FocusAdapter(){
public void focusGained(FocusEvent e){}
public void focusLost(FocusEvent e){
if( !e.isTemporary() ){
JOptionPane.showMessageDialog(null, "Focus lost in 1");
field1.requestFocus(); //- This makes the focus to be called again
}
}
});
frame.getContentPane().add(field1, BorderLayout.WEST);
frame.getContentPane().add(field2, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setBounds(0,0,200,300);
frame.show();
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6555704 Extra focus gain & focus lost event is triggered in win xp.
-
- Closed
-
-
JDK-6519541 focusLost event is generated multiple times
-
- Closed
-
-
JDK-6212464 Undesired JOptionPane loop in FocusLost event
-
- Closed
-
- relates to
-
JDK-6411406 Components automatically transfer focus on removal, even if developer requests focus elsewhere first
-
- Closed
-