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

javax.swing.JLabel: displayedMnemonic don't respect an disabled Component

    XMLWordPrintable

Details

    • kestrel
    • generic
    • generic

    Description



      Name: skT88420 Date: 06/09/99


      - bind a JTextField to a JLabel via label.setLabelFor(textField)
      - set a valid mnemonic on the label using label.setDisplayedMnemonic(..)
      - disable the Textfield
      - activate the Mnemonic of the label
      - the focus is set on the Textfield, the cursor is blinking,
        and deleting can be performed --> BUG

      Here is a small test case:

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

      public class LabelBug
      {
        public static void main(String[] argv)
        {
          JLabel header = new JLabel("Press <ALT-E>: you can navigate and delete");

          JTextField textField = new JTextField("This is the text to be removed", 20);
          textField.setEnabled(false);

          JLabel label = new JLabel("Enter your text here");
          label.setLabelFor(textField);
          label.setDisplayedMnemonic('e');

          JButton button = new JButton("Press");
          button.setMnemonic('p');

          JFrame frame = new JFrame("LabelFor Bug");
          frame.getContentPane().setLayout(new BorderLayout());
          frame.getContentPane().add(header, BorderLayout.NORTH);
          frame.getContentPane().add(label, BorderLayout.WEST);
          frame.getContentPane().add(textField, BorderLayout.CENTER);
          frame.getContentPane().add(button, BorderLayout.SOUTH);

          frame.addWindowListener(new WindowAdapter()
            {
              public void windowClosing(WindowEvent E)
              {
                System.exit(0);
              }
            });

          frame.pack();
          frame.show();

          // -- yes, this is not thread safe, but an initial focus is needed --
          button.requestFocus();
        }
      }

      Look at the source code of javax.swing.plaf.basic.BasicLabelUI:
      inner classes PressAction und ReleaseAction don't respect if the
      target component is disabled.
      (Review ID: 84113)
      ======================================================================

      Attachments

        Activity

          People

            jeff Jeff Dinkins
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: