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

JButton.setFocusPainted() not working as expected in Nimbus Look and feel

    Details

      Description

      OPERATING SYSTEM(S):
      Linux 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686 i686 i386 GNU/Linux

      FULL JDK VERSION(S):
      java version "1.6.0_14-ea"
      Java(TM) SE Runtime Environment (build 1.6.0_14-ea-b04)
      Java HotSpot(TM) Client VM (build 14.0-b13, mixed mode)

      DESCRIPTION:
      A set of JCK-Runtime-6b JButton interactive testcases are failing with the above mentioned JDK. Specifically:

        JButtonTest0002
        JButtonTest0004
        JButtonTest0005
        JButtonTest0010
        JButtonTest0011

      Following is a cut down version where the JButton.setFocusPainted() method functionality is tested.

      TestClass.java:

      import java.awt.BorderLayout;
      import java.awt.Graphics;
      import java.awt.event.ActionEvent;
      import java.awt.event.InputEvent;
      import java.awt.event.KeyEvent;
      import javax.swing.AbstractAction;
      import javax.swing.Action;
      import javax.swing.JButton;
      import javax.swing.KeyStroke;
      import javax.swing.*;
      import java.awt.*;

      public class TestClass {
        public static void main(String args[]) {
          JFrame frame = new JFrame("Nimbus Look & Feel Testcase");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          final Action printAction = new PrintHelloAction();

          JButton fileButton = new JButton("Click");

         // I have made setFocusPaint to true & if run with nimbus look & feel option one can really see the differnece

           fileButton.setFocusPainted(true);
          fileButton.addActionListener(printAction);

          // The default & size 0 is same for nimbus l&f but its different for normal(ie without nimbus l&f option )
          fileButton.setMargin(new Insets(5,5,5,5));

          frame.add(fileButton, BorderLayout.SOUTH);
          frame.setSize(300, 100);
          frame.setVisible(true);
        }
      }

      class PrintHelloAction extends AbstractAction {
        public void actionPerformed(ActionEvent actionEvent) {
          System.out.println("Works Fine");
        }
      }

      Steps To Reproduce:
      1. javac TestClass.java
      2. java -Dswing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel TestClass

      Failing Behaviour:
      Even though the "paintFocus" property is set to true via JButton.setFocusPainted(true), the text in the button image ("Click") is not focus painted in Nimbus Look and feel. It is painted correctly in all other look and feels.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dkorbel David Korbel (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: