JDK-4799500 : dead key pressed/released twice should produce non-dead character on Unix
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: linux_redhat_6.1
  • CPU: x86
  • Submitted: 2003-01-07
  • Updated: 2006-01-12
  • Resolved: 2006-01-12
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
Non-Java applications can produce ascii versions of dead keys by typing 
the dead key twice in a row.  For example, in a German xmodmap, dead-acute pressed and released twice produces apostrophe.  dead-circumflex pressed and released twice produces ascii circumflex.  

The test case below can be used to see that this does not work in JDK1.4.2 
with lightweight TextComponents (including Swing).  

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;        

public class MySwingTest extends JApplet implements KeyListener, ActionListener {

    JTextField jtf = null; 
    JTextArea jta = null; 

    public static void main(String[] args) {
        JFrame frame = new JFrame("MySwingTest");
        JPanel p = new JPanel();

        MySwingTest applet = new MySwingTest();
        applet.init();

        p.add("Center", applet);
        frame.getContentPane().add(p);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setSize(850, 200);
        frame.setVisible(true);

        applet.start();
    }

    public void init() { 
        JLabel jl = new JLabel("Enter characters");

        jtf = new JTextField("Hello World", 20);
        jtf.addKeyListener(this);
        jtf.addActionListener(this);
        jta = new JTextArea("Hello World", 4, 30);
        jta.addKeyListener(this);

        // the default layout manager for a JApplet is a BorderLayout 
        this.getContentPane().setLayout(new FlowLayout());
        this.getContentPane().add(jl, FlowLayout.LEFT);
        this.getContentPane().add(jtf, FlowLayout.CENTER);
        this.getContentPane().add(jta, FlowLayout.RIGHT);
    }

    public void start() { 
        jtf.requestFocus();
    }

    public void keyPressed(KeyEvent evt)
    {
        printKey(evt);
    }

    public void keyTyped(KeyEvent evt)
    {
        printKey(evt);
    }

    public void keyReleased(KeyEvent evt)
    {
        printKey(evt);
        System.out.print("\n");
    }

    public void actionPerformed(ActionEvent evt)
    {
        System.out.print("\n");
        System.out.print("Action Event\n");
        System.out.println(evt.toString());
        System.out.print("\n");
    }

    protected void printKey(KeyEvent evt)
    {
        switch(evt.getID())
        {
          case KeyEvent.KEY_TYPED:
            break;
          case KeyEvent.KEY_PRESSED:
            break;
          case KeyEvent.KEY_RELEASED:
            break;
          default:
            System.out.println("Other Event ");
            return;
        }

        System.out.print("params= " + evt.paramString() + "  \n" +
          "KeyChar: " + evt.getKeyChar() + " = " + (int) evt.getKeyChar() +
          "   KeyCode: " + evt.getKeyCode() +
          "   Modifiers: " + evt.getModifiers());
        if (evt.isActionKey())
            System.out.print("   Action Key");
        System.out.print("\n");

        System.out.println("keyText= " + evt.getKeyText(evt.getKeyCode())
          + "\n");
    }

}

Comments
EVALUATION Fixed under umbrella 4360364.
12-01-2006

EVALUATION Commit to fix in Tiger. ###@###.### 2003-01-06 One of the issues raised in 4797332 is in regard to dead-key, dead-key when used in conjunction with the Compose key on Solaris. I found that when using my usual US xmodmap on Solaris 2.7 (sparc) and xev, Compose followed by grave, grave produced a quote (according to XLookupString). Perhaps if we changed over to XLookupString from the problematic XtTranslateKeycode, this would fix the problem. KeyPress event, serial 23, synthetic NO, window 0xdc00001, root 0x25, subw 0xdc00002, time 2771658891, (42,36), root:(852,162), state 0x0, keycode 74 (keysym 0xff20, Multi_key), same_screen YES, XLookupString gives 0 characters: "" KeyRelease event, serial 23, synthetic NO, window 0xdc00001, root 0x25, subw 0xdc00002, time 2771659022, (42,36), root:(852,162), state 0x0, keycode 74 (keysym 0xff20, Multi_key), same_screen YES, XLookupString gives 0 characters: "" KeyPress event, serial 23, synthetic NO, window 0xdc00001, root 0x25, subw 0xdc00002, time 2771660160, (42,36), root:(852,162), state 0x0, keycode 49 (keysym 0x60, grave), same_screen YES, XLookupString gives 0 characters: "" KeyRelease event, serial 23, synthetic NO, window 0xdc00001, root 0x25, subw 0xdc00002, time 2771660277, (42,36), root:(852,162), state 0x0, keycode 49 (keysym 0x60, grave), same_screen YES, XLookupString gives 0 characters: "" KeyPress event, serial 23, synthetic NO, window 0xdc00001, root 0x25, subw 0xdc00002, time 2771662543, (42,36), root:(852,162), state 0x0, keycode 49 (keysym 0x60, grave), same_screen YES, XLookupString gives 1 characters: "`" KeyRelease event, serial 23, synthetic NO, window 0xdc00001, root 0x25, subw 0xdc00002, time 2771662689, (42,36), root:(852,162), state 0x0, keycode 49 (keysym 0x60, grave), same_screen YES, XLookupString gives 1 characters: "`" ###@###.### 2003-01-09 Apparently, XLookupString does not allow for composing characters. See sections 9.1.1 and 11 of the Xlib programming manual Volume 1 (Jan. 1995). It is suggested that XmbLookupString or XwcLookupString be used instead. We have had problems with XmbLookupString in the past. Perhaps we will have to revisit this issue and see if we can make it work. I'm kind of surprised to read the claim that it XLookupString won't work, though. It seems to work fine with xev using a German xmodmap on Solaris 9 (sparc). Alternately, I've heard that XtSetLanguageProc can help, but we are trying to remove our dependency on Xt. ###@###.### 2003-07-06
06-07-2003