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

Nimbus: Setting Nimbus.Overrides property affects custom keymap installation

    XMLWordPrintable

Details

    • b23
    • x86
    • linux_ubuntu

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0_55"
      Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
      Java HotSpot(TM) Server VM (build 24.55-b03, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux davmac-bjdesktop 3.2.0-58-generic-pae #88-Ubuntu SMP Tue Dec 3 18:00:02 UTC 2013 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      When using the Nimbus look-and_feel, and the Nimbus.Overrides property is set on a JEditorPane, any custom keymap setting on the pane appears to have no effect. This is true even if the Nimbus.Overrides property is set to an empty property table.

      Also seen on Windows.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Programmatically (see provided testcase):
      1. Set the Nimbus look-and-feel to be the active look-and-feel
      2. Create a frame containing a javax.swing.JEditorPane
      3. Set the "Nimbus.Overrides" client property on the JEditorPane to an empty (new) UIDefaults instance
      4. Set the keymap on the editor pane to a custom keymap, with the space key bound to an action which displays a popup dialog
      5. User: run program and press space

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The custom action should fire; a dialog should be displayed.
      ACTUAL -
      The custom action does not fire. A space is inserted in the JEditorPane document.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.Dimension;
      import java.awt.EventQueue;
      import java.awt.event.ActionEvent;

      import javax.swing.AbstractAction;
      import javax.swing.JEditorPane;
      import javax.swing.JFrame;
      import javax.swing.JOptionPane;
      import javax.swing.JPanel;
      import javax.swing.KeyStroke;
      import javax.swing.UIDefaults;
      import javax.swing.UIManager;
      import javax.swing.text.Keymap;


      public class TestFrame extends JFrame
      {
          public static void main(String [] args) {
              try {
              EventQueue.invokeAndWait(new Runnable() {
                 @Override
                  public void run()
                  {
                     try {
                         UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
                     }
                     catch(Exception e) {
                         e.printStackTrace();
                         System.exit(1);
                     }
                     
                     TestFrame tf = new TestFrame();
                     tf.pack();
                     tf.setVisible(true);
                  }
              });
              }
              catch (Exception e) {
                  e.printStackTrace();
                  System.exit(1);
              }
          }
          
          public TestFrame()
          {
              setDefaultCloseOperation(DISPOSE_ON_CLOSE);
              
              /*
               * Create a frame containing a JEditorPane, and override the action for the space bar to show
               * a dialog.
               */
              
              JEditorPane pp = new JEditorPane();

              UIDefaults defaults = new UIDefaults();

              /** COMMENT THIS LINE TO SEE CORRECT BEHAVIOUR */
              pp.putClientProperty("Nimbus.Overrides", defaults);
              
              JPanel contentPanel = new JPanel();
              contentPanel.setLayout(new BorderLayout());
              setContentPane(contentPanel);
              
              contentPanel.setPreferredSize(new Dimension(400, 300));
              contentPanel.add(pp, BorderLayout.CENTER);
              
              Keymap origKeymap = pp.getKeymap();
              Keymap km = JEditorPane.addKeymap("Test keymap", origKeymap);
              
              km.addActionForKeyStroke(KeyStroke.getKeyStroke(' '), new AbstractAction("SHOW_SPACE") {
                 @Override
                  public void actionPerformed(ActionEvent e)
                  {
                     JOptionPane.showMessageDialog(TestFrame.this, "Space!");
                  }
              });
              
              pp.setKeymap(km);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Not known.

      Attachments

        Activity

          People

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: