Let jme swing supports multi byte characters

  I use Chinese language. But the BUI or the FengGUI don't support multi-byte characters. So I choiced the swing gui. The good news is that swing gui supports display multi-byte characters, but doesn't support input. So I debugged jme and got a solution as following.

  Find file JMEDesktop.java, add a field:

      private byte last;

  Find method sendAWTKeyEvent, modify it as following:

      Component focusOwner = getFocusOwner();

if (focusOwner == null) {

focusOwner = desktop;

}

if (keyCode == 0) {

if (character >= 0x1a) {

if (last == 0x0) {

last = (byte) character;//the first byte of multi-byte charater

return;

} else {

if (last != (byte) 0) {

String temp = new String(new byte[] { last,

(byte) character });

character = temp.charAt(0);

last = (byte) 0;

if (focusOwner != null) {

dispatchEvent(focusOwner, new KeyEvent(

focusOwner, KeyEvent.KEY_TYPED, System

.currentTimeMillis(),

getCurrentModifiers(-1), 0, character));

return;

}

}

}

last = (byte) 0;

}

last = (byte) 0;

} else {

last = (byte) 0;

}



    then follows the existing code as

        keyCode = AWTKeyInput.toAWTCode(keyCode);

      …

    And delete

        Component focusOwner = getFocusOwner();

        … (3 lines)

    and that's it.