src/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java

Print this page


   1 /*
   2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.apple.laf;
  27 
  28 import sun.swing.SwingUtilities2;
  29 
  30 import javax.swing.*;
  31 import java.awt.*;
  32 

  33 class AquaComboBoxRendererInternal extends JLabel implements ListCellRenderer {
  34     final JComboBox fComboBox;
  35     boolean fSelected;
  36     boolean fChecked;
  37     boolean fInList;
  38     boolean fEditable;
  39     boolean fDrawCheckedItem = true;
  40 
  41     // Provides space for a checkbox, and is translucent
  42     public AquaComboBoxRendererInternal(final JComboBox comboBox) {
  43         super();
  44         fComboBox = comboBox;
  45     }
  46 
  47     // Don't include checkIcon space, because this is also used for button size calculations
  48     // - the popup-size calc will get checkIcon space from getInsets
  49     public Dimension getPreferredSize() {
  50         // From BasicComboBoxRenderer - trick to avoid zero-height items
  51         final Dimension size;
  52 


   1 /*
   2  * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.apple.laf;
  27 
  28 import sun.swing.SwingUtilities2;
  29 
  30 import javax.swing.*;
  31 import java.awt.*;
  32 
  33 @SuppressWarnings("serial") // Superclass is not serializable across versions
  34 class AquaComboBoxRendererInternal extends JLabel implements ListCellRenderer {
  35     final JComboBox fComboBox;
  36     boolean fSelected;
  37     boolean fChecked;
  38     boolean fInList;
  39     boolean fEditable;
  40     boolean fDrawCheckedItem = true;
  41 
  42     // Provides space for a checkbox, and is translucent
  43     public AquaComboBoxRendererInternal(final JComboBox comboBox) {
  44         super();
  45         fComboBox = comboBox;
  46     }
  47 
  48     // Don't include checkIcon space, because this is also used for button size calculations
  49     // - the popup-size calc will get checkIcon space from getInsets
  50     public Dimension getPreferredSize() {
  51         // From BasicComboBoxRenderer - trick to avoid zero-height items
  52         final Dimension size;
  53