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

JButton constructor ignoring Action.MNEMONIC_KEY

XMLWordPrintable

    • beta
    • generic, x86
    • generic, windows_nt



      Name: yyT116575 Date: 10/27/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      The constructor of JButton that takes an action ignores the MNEMONIC_KEY if it
      is specified. The following code should display a line under the 'p' but it
      doesn't.

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

      public class Test {
          public static void main( final String args[] ) {
              final AbstractAction action = new AbstractAction() {
                  public void actionPerformed( final ActionEvent event ) {
                      // Do nothing
                  }
              };

              final JFrame frame = new JFrame("Toolbar tester");
              frame.getContentPane().setLayout( new FlowLayout() );

              action.putValue( Action.NAME, "Push me" );
              action.putValue( Action.MNEMONIC_KEY, new Integer((int)'p') );

              frame.getContentPane().add( new JButton(action) );

              frame.setSize(400,200);
              frame.show();
          }
      }
      (Review ID: 110939)
      ======================================================================

            peterz Peter Zhelezniakov
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: