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".

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.

weird...sounds like it could be a keyboard mapping issue? Stupid I know, but have you made sure the numpad lock is on and works as expected in other red hat applications?
–
bcrJul 10 '12 at 17:44

Numpad lock is on, and everything works fine when typing in other programs. I also tried using a different keyboard -- no luck.
–
lrAndroidJul 10 '12 at 17:53

Found something here: rvdavid.net/… It's Ubuntu of course, but could it be something similar in your case?
–
vaisakhJul 10 '12 at 17:59

Thanks for the suggestion, but that doesn't fix it -- my numpad is still allowing me to type numbers, the problem is the actions that it sends before the numbers are typed.
–
lrAndroidJul 10 '12 at 18:05

Is the rest of the keyboard working fine under linux?
–
RorchackhJul 14 '12 at 0:06

Well it is hard to give an accurate answer why but it is not really a weird phenomena. Usually when a VNC or remote desktop sharing happens, the keyboard and mouse events of one machine are transmitted to an other machine. When this mapping is done, there could be a fair chance that there might be erroneous behavior especially with the clipboard copy, pasting. It happens not just in the Linux world but also in the windows world.

I tell this by own experience. At my workplace we often rdc into other machines, some running XP and some running Windows 7. The action of clipboard copy on one machine and pasting on remote machine works on some systems and fails on others.

Quoting another such experience with java and remote desktop access, I've a java application running on my eclipse. When I rdc into my machine from some of the other machines, I find that eclipse is completely unable to launch the application. For it to work, I need to launch it on my own system first, keep the application running and then rdc from an other into mine.

Just to imagine, if this is the case with Windows XP and Windows 7 which are known belong to the same family. One can only hope that something wacky like that might not occur when using Linux and Windows together with VNC :)

As said, It is hard to be too accurate about why it is happening but it can be surely said that this is purely something that happens at the OS to OS level and not at the swing framework level.

There is one common problem which can cause this. If a modifier key, such as Shift, Ctrl or Alt, is pressed, and the viewer window then loses focus or dies, the 'key release' message never gets to the viewer and hence never gets to the remote server. The remote machine will then think that M is Ctrl-M etc. We have done various things to reduce the chance of this happening; the viewers release various modifiers automatically when they lose focus, for example, but it can still occur and can be confusing when it does. The solution is easy: simply press and release the modifier key which is stuck. If you don't know which it is, then try them one at a time.

If this information is indicative of your problem, then it may be that when the problem "magically disappeared," the Num Pad was simply in sync with VNC on that day and out of sync on the others (which of course means that the issue could crop up again).

Why, then, would the issue only occur within the Java program (created via Eclipse), but not occur within any other programs? Additionally, the issue is only with numpad keys, not the entire keyboard. Furthermore, what modifier key could even cause the "0" key on the numpad to paste?
–
lrAndroidJul 18 '12 at 18:32

So when you use the Num Pad in other applications (on Red Hat via VNC) it works fine at the same time that it is malfunctioning in the Java program?
–
asteriJul 18 '12 at 18:35

Correct. The issue only seemed to be happening within my Java programs.
–
lrAndroidJul 18 '12 at 18:38