1 /*
2 * Copyright (c) 1997, 2005, 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
30
31 import java.awt.*;
32
33 import java.io.Serializable;
34
35
36 /**
37 * ComboBox renderer
38 * <p>
39 * <strong>Warning:</strong>
40 * Serialized objects of this class will not be compatible with
41 * future Swing releases. The current serialization support is
42 * appropriate for short term storage or RMI between applications running
43 * the same version of Swing. As of 1.4, support for long term storage
44 * of all JavaBeans™
45 * has been added to the <code>java.beans</code> package.
46 * Please see {@link java.beans.XMLEncoder}.
47 *
48 * @author Arnaud Weber
49 */
50 public class BasicComboBoxRenderer extends JLabel
51 implements ListCellRenderer, Serializable {
52
53 /**
54 * An empty <code>Border</code>. This field might not be used. To change the
55 * <code>Border</code> used by this renderer directly set it using
56 * the <code>setBorder</code> method.
57 */
58 protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
59 private final static Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
60
61 public BasicComboBoxRenderer() {
62 super();
63 setOpaque(true);
64 setBorder(getNoFocusBorder());
65 }
66
67 private static Border getNoFocusBorder() {
68 if (System.getSecurityManager() != null) {
69 return SAFE_NO_FOCUS_BORDER;
122 }
123 return this;
124 }
125
126
127 /**
128 * A subclass of BasicComboBoxRenderer that implements UIResource.
129 * BasicComboBoxRenderer doesn't implement UIResource
130 * directly so that applications can safely override the
131 * cellRenderer property with BasicListCellRenderer subclasses.
132 * <p>
133 * <strong>Warning:</strong>
134 * Serialized objects of this class will not be compatible with
135 * future Swing releases. The current serialization support is
136 * appropriate for short term storage or RMI between applications running
137 * the same version of Swing. As of 1.4, support for long term storage
138 * of all JavaBeans™
139 * has been added to the <code>java.beans</code> package.
140 * Please see {@link java.beans.XMLEncoder}.
141 */
142 public static class UIResource extends BasicComboBoxRenderer implements javax.swing.plaf.UIResource {
143 }
144 }
|
1 /*
2 * Copyright (c) 1997, 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
30
31 import java.awt.*;
32
33 import java.io.Serializable;
34
35
36 /**
37 * ComboBox renderer
38 * <p>
39 * <strong>Warning:</strong>
40 * Serialized objects of this class will not be compatible with
41 * future Swing releases. The current serialization support is
42 * appropriate for short term storage or RMI between applications running
43 * the same version of Swing. As of 1.4, support for long term storage
44 * of all JavaBeans™
45 * has been added to the <code>java.beans</code> package.
46 * Please see {@link java.beans.XMLEncoder}.
47 *
48 * @author Arnaud Weber
49 */
50 @SuppressWarnings("serial") // Same-version serialization only
51 public class BasicComboBoxRenderer extends JLabel
52 implements ListCellRenderer, Serializable {
53
54 /**
55 * An empty <code>Border</code>. This field might not be used. To change the
56 * <code>Border</code> used by this renderer directly set it using
57 * the <code>setBorder</code> method.
58 */
59 protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
60 private final static Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
61
62 public BasicComboBoxRenderer() {
63 super();
64 setOpaque(true);
65 setBorder(getNoFocusBorder());
66 }
67
68 private static Border getNoFocusBorder() {
69 if (System.getSecurityManager() != null) {
70 return SAFE_NO_FOCUS_BORDER;
123 }
124 return this;
125 }
126
127
128 /**
129 * A subclass of BasicComboBoxRenderer that implements UIResource.
130 * BasicComboBoxRenderer doesn't implement UIResource
131 * directly so that applications can safely override the
132 * cellRenderer property with BasicListCellRenderer subclasses.
133 * <p>
134 * <strong>Warning:</strong>
135 * Serialized objects of this class will not be compatible with
136 * future Swing releases. The current serialization support is
137 * appropriate for short term storage or RMI between applications running
138 * the same version of Swing. As of 1.4, support for long term storage
139 * of all JavaBeans™
140 * has been added to the <code>java.beans</code> package.
141 * Please see {@link java.beans.XMLEncoder}.
142 */
143 @SuppressWarnings("serial") // Same-version serialization only
144 public static class UIResource extends BasicComboBoxRenderer implements javax.swing.plaf.UIResource {
145 }
146 }
|