-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.1
-
x86
-
windows_2000
Name: rmT116609 Date: 10/01/2002
FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
also:
java version "1.4.0"
Java(TM) Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b2, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195], Solaris 2.8
A DESCRIPTION OF THE PROBLEM :
I have multiple JTextFields that are used to accept numeric input. On those JTextFields, I have specified FocusListeners to verify the input. If I leave a
JTextField blank (which isn't supposed to be allowed) and leave the JFrame completely, my JOptionPane error message displays on the screen as an outline. All execution at this point halts and the VM has to be restarted. This
result was seen with all versions of java about 1.4
I have tried this identical situation with 1.3 and this does not happen.
REGRESSION. Last worked in version 1.3.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Copy the code and compile using 1.4 then run it:
2. Enter an invalid entry like "abcd" and click off the JFrame so the JFrame loses focus. You should receive a blank error box and the program should freeze.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Upon clicking off the JFrame, I should receive a full error box with an "OK" button. I should be able to click on this button to restore control to the JFrame. This never happens and I am unable to gain control of the
application. Using Java 1.3, the error box displays as it should.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages received
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Test extends JFrame implements FocusListener
{
private JTextField text = new JTextField(15),
text1 = new JTextField(15);
private JLabel label = new JLabel("Numeric Input:"),
label1 = new JLabel("Another Numeric Input");
/** Creates a new instance of Test */
public Test() {
init();
}
private void init()
{
text.setText("0");
text1.setText("0");
text.addFocusListener(this);
text1.addFocusListener(this);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(label);
getContentPane().add(text);
getContentPane().add(label1);
getContentPane().add(text1);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public void focusGained(java.awt.event.FocusEvent focusEvent) {
((JTextField)focusEvent.getSource()).selectAll();
}
public void focusLost(java.awt.event.FocusEvent focusEvent) {
if (! verifyInput((JTextField)focusEvent.getSource()))
JOptionPane.showMessageDialog(this, "Invalid number
entered", "Error", JOptionPane.ERROR_MESSAGE);
}
private boolean verifyInput(JTextField txt)
{
int input;
if (! txt.getText().equalsIgnoreCase(""))
{
try{
input = Integer.parseInt(txt.getText());
}
catch (NumberFormatException nfe)
{
txt.setText("0");
return false;
}
}
else
return false;
return true;
}
public static void main(String args[])
{
new Test();
}
}
---------- END SOURCE ----------
Release Regression From : 1.3.1_05
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 165179)
======================================================================
- duplicates
-
JDK-4531693 Deadlock while showing a modal dialog from inkoveAndWait().
-
- Resolved
-