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

[macosx] JComboBox paints the border incorrectly

    XMLWordPrintable

Details

    • b16
    • x86
    • os_x

    Backports

      Description

        FULL PRODUCT VERSION :
        Java 7 & 8, 8u5 and 8u11 recently confirmed to exhibit the issue.

        ADDITIONAL OS VERSION INFORMATION :
        Mac OS X 10.9.4

        A DESCRIPTION OF THE PROBLEM :
        The blue fuzzy border which is supposed to paint around a combo box only paints around the button part of the combo box.

        Instead of the proper border around the editor, the editor highlights internally, which does not match native component behaviour.

        Additionally, the height of the editor for the combo box does not match the height of the button, nor does it match the height of other text fields - all diversions from the native look of the corresponding components.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the attached test program.


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.swing.JComboBox;
        import javax.swing.JFrame;
        import javax.swing.JLabel;
        import javax.swing.JPanel;
        import javax.swing.SwingUtilities;
        import javax.swing.WindowConstants;
        import java.awt.FlowLayout;

        public class ComboBoxPaintingTest implements Runnable {
            public static void main(String[] args) {
                SwingUtilities.invokeLater(new ComboBoxPaintingTest());
            }

            @Override
            public void run() {
                JLabel label = new JLabel("Editable combo box:");

                // Notice that the button positioning is incorrect and that the highlighting does
                // not go all the way around the combo box.
                JComboBox<String> comboBox = new JComboBox<>(new String[] { "Item 1", "Item 2", "Item 3" });
                comboBox.setEditable(true);

                FlowLayout layout = new FlowLayout(FlowLayout.LEADING);
                layout.setAlignOnBaseline(true);
                JPanel panel = new JPanel(layout);
                panel.add(label);
                panel.add(comboBox);

                JFrame frame = new JFrame();
                frame.setContentPane(panel);
                frame.pack();
                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        I haven't found a workaround for the fuzzy border itself. There is a post on the Apple development list from 2009 suggesting that they might add a way to draw that border manually, but I don't think it was ever implemented.

        Haqua has a workaround for the height of the text box being wrong and the kick-on issue of the baseline then being wrong. I have worked around the editable and non-editable combo boxes being the wrong size, but text fields are still slightly different to editable combo boxes.

        Attachments

          Issue Links

            Activity

              People

                dnguyen Damon Nguyen
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: