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

Visual changes of JToggleButton#setBorderPainted(false)

XMLWordPrintable

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      We call JToggleButton#setBorderPainted(false).
      With Java 9 and Windows LF (other LF not tested) the button has no longer a visual inidicator when the button is toggled in contrary to Java 8 where the button is light-blue-gray.

      Tested with Java 9 b177, 8 u102, 8 u131, 8 u144 on Windows 7 and Windows 2012 R2.

      It was recommended to fill a bug for this:
      http://mail.openjdk.java.net/pipermail/swing-dev/2017-July/007663.html


      REGRESSION. Last worked in version 8u144

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the reproducer.
      Toggle/untoggle the JToggleButton and see that there is no visual difference (set focus to JTextField after toggle/untoggle).


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.BorderFactory;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JTextField;
      import javax.swing.JToggleButton;
      import javax.swing.UIManager;
      import javax.swing.WindowConstants;
      import java.awt.BorderLayout;
      import java.awt.EventQueue;

      public final class Reproducer {
        public static void main(String[] args) throws Exception {
          EventQueue.invokeAndWait(new Runnable() {
            @Override
            public void run() {
              try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {
                e.printStackTrace();
                System.exit(1);
              }
            }
          });

          EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
              JTextField text = new JTextField();

              JToggleButton button = new JToggleButton("Test");
              button.setBorderPainted(false);

              JPanel pane = new JPanel(new BorderLayout());
              pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
              pane.add(text, BorderLayout.NORTH);
              pane.add(button, BorderLayout.SOUTH);

              JFrame frame = new JFrame();
              frame.getContentPane().add(pane);
              frame.setSize(200, 200);
              frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              frame.setVisible(true);
            }
          });
        }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Do not call JToggleButton#setBorderPainted(false).

        1. 8u144.png
          8u144.png
          2 kB
        2. 9.PNG
          9.PNG
          4 kB
        3. Reproducer.java
          1 kB

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

              Created:
              Updated:
              Resolved: