Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6492266

Cannot select a Java input method in an WebStarted application

XMLWordPrintable

    • b86
    • 6
    • b10
    • generic, x86
    • generic, windows_xp
    • Verified

        How to reproduce:

        1. Install some input method, e.g., CodePointIM demo into 'lib/ext' directory.
        2. Run some Swing WebStart application that have a text field, e.g., Bugster.
        3. Move focus to the text field.
        4. Bring up the 'input method selection' pop up menu. On Windows, click on the system icon on the top-left corner of the frame and then select "Select Input Method" menu item.
        5. Popup menu is actually displayed, but you cannot operate with it.

        This seems to happen on Java 6 only. I could not reproduce it with 1.5.0_06.
        I found one more regression of 6280964:

        Look at the lines in BasicPopupMenuUI.installListeners() :

        if (!menuKeyboardHelperInstalled) {
            if (menuKeyboardHelper == null) {
                menuKeyboardHelper = new MenuKeyboardHelper();
            }
            MenuSelectionManager msm = MenuSelectionManager.defaultManager();
            msm.addChangeListener(menuKeyboardHelper);
            menuKeyboardHelperInstalled = true;
        }

        Here menuKeyboardHelper is a static variable. Now only one instance of MenuKeyboardHelper is shared between all MenuSelectionManagers (and all EDTs). menuKeyboardHelper static field should be replaced by a variable in AppContext (as MouseGrabber at couple of lines above).
        Copied from the description of 6484971:

        JMenu works unstable when two applets work in different AppContexts,
        sometimes they don't respond to key events like stop to move the menu selection
        by arrow buttons and stop to react on menuItem's accelerators

        How to reproduce:
        run the provided applet in one JVM but in differect AppContext's
        e.g. in Mozilla you should copy class files to two differect directories
        and launch them in two browser's instances

        To make sure check the console,
        you need to have the same "Singleton" value
        and the different AppContext.getAppContext().hashCode() value

        Play with the menus of both applets several times,
        you will the the described problems

        JDK 1.5 and 1.6

        import sun.awt.AppContext;
        import javax.swing.*;
        import java.awt.event.InputEvent;
        import java.awt.event.KeyEvent;
        import java.awt.event.ActionListener;
        import java.awt.event.ActionEvent;

        public class MenuTest extends JApplet {

            public void init() {
                System.out.println("Singleton = " + ToolTipManager.sharedInstance().hashCode());
                System.out.println("AppContext.getAppContext().hashCode() = " + AppContext.getAppContext().hashCode());

                JMenu menu = new JMenu("Menu");
                menu.setMnemonic('m');
                menu.add(new JMenuItem("item"));
                JMenuItem item = new JMenuItem("item");
                item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK));
                item.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        JOptionPane.showConfirmDialog(MenuTest.this, "Is everything ok ?");
                    }
                });
                menu.add(item);
                menu.add(new JMenuItem("item"));

                JMenuBar bar = new JMenuBar();
                bar.add(menu);
                setJMenuBar(bar);
            }
        }

              mlapshin Mikhail Lapshin (Inactive)
              naoto Naoto Sato
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: