Hi,
I've tested this small application (jdk116-v2 with a RH 5.1) and
I've discovered a memory corruption:
when the focus is lost from the TextField I assign 0 to the local
variable var1, if the parseInt throws an exception (i.e. I don't
write ant value in TF) the content of var1 is corrupted: it assumes
some apparently random values when I click outside and inside the window.
If I run the application without tya the problem disappear.
Bye
Fulco
--------------------------- Main.java ---------------------------
import java.awt.event.*;
import java.awt.*;
class Main extends Frame {
TextField t1;
public Main() {
super("Test");
setSize(250,100);
setLayout(new FlowLayout());
add(t1 = new TextField(5));
t1.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
int var1,var2;
var1 = 0;
try {
var2 = Integer.parseInt(t1.getText());
} catch (NumberFormatException nfe) {
var2 = 0;
}
// var1 is corrupted if parseInt throws his exception!!!
System.out.println("var1: " + var1 + ",var2: " + var2);
}
});
show();
}
public static void main( String[] args ) {
Main mytest = new Main();
}
}