I've recently run into a strange issue with the Java JTextField. When I run the following code (see below), typing a "0" into the text field first sends a paste action, then types "0". For example, if "text" is copied to the clipboard, "text0" is typed when I type "0". Similarly, typing a "4" replaces the previous character with a "4" (I'm guessing this is a delete action, then the "4" is typed). Typing "7" clears the text field before typing "7".
Here is the code:
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame();
JTextField text = new JTextField();
frame.add(text);
frame.setSize(500, 500);
frame.setVisible(true);
}
}
The problem is occurring on Red Hat Linux (accessed using VNC from Windows XP); everything runs as expected on Window XP.
Update: No problems with the program on Ubuntu either. I've also tried using different keyboards and VNC viewers.
Update 2: Java Versions
For Red Hat:
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.7) (rhel-1.17.b17.el5-x86_64)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
For XP:
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode, sharing)
Update 3: Tried running the program on three different Red Hat machines (all in the same group at work), and additionally tried running it from a different XP computer and restarting.
Update 4: Today I arrived at work to find that the problem had magically gone away. However, it'd really be nice to know why it happened in the first place so that I (and anyone else who many encounter this strange issue) know how to fix it in the future.