1 /*
2 * Copyright (c) 2002, 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
179 style = null;
180 }
181
182 /**
183 * {@inheritDoc}
184 */
185 @Override
186 public SynthContext getContext(JComponent c) {
187 return getContext(c, getComponentState(c));
188 }
189
190 private SynthContext getContext(JComponent c, int state) {
191 return SynthContext.getContext(SynthContext.class, c,
192 SynthLookAndFeel.getRegion(c), style, state);
193 }
194
195 private int getComponentState(JComponent c) {
196 return SynthLookAndFeel.getComponentState(c);
197 }
198
199
200 private class SynthListCellRenderer extends DefaultListCellRenderer.UIResource {
201 @Override public String getName() {
202 return "List.cellRenderer";
203 }
204
205 @Override public void setBorder(Border b) {
206 if (useUIBorder || b instanceof SynthBorder) {
207 super.setBorder(b);
208 }
209 }
210
211 @Override public Component getListCellRendererComponent(JList list, Object value,
212 int index, boolean isSelected, boolean cellHasFocus) {
213 if (!useListColors && (isSelected || cellHasFocus)) {
214 SynthLookAndFeel.setSelectedUI((SynthLabelUI)SynthLookAndFeel.
215 getUIOfType(getUI(), SynthLabelUI.class),
216 isSelected, cellHasFocus, list.isEnabled(), false);
217 }
218 else {
219 SynthLookAndFeel.resetSelectedUI();
|
1 /*
2 * Copyright (c) 2002, 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
179 style = null;
180 }
181
182 /**
183 * {@inheritDoc}
184 */
185 @Override
186 public SynthContext getContext(JComponent c) {
187 return getContext(c, getComponentState(c));
188 }
189
190 private SynthContext getContext(JComponent c, int state) {
191 return SynthContext.getContext(SynthContext.class, c,
192 SynthLookAndFeel.getRegion(c), style, state);
193 }
194
195 private int getComponentState(JComponent c) {
196 return SynthLookAndFeel.getComponentState(c);
197 }
198
199 @SuppressWarnings("serial") // Superclass is not serializable across versions
200 private class SynthListCellRenderer extends DefaultListCellRenderer.UIResource {
201 @Override public String getName() {
202 return "List.cellRenderer";
203 }
204
205 @Override public void setBorder(Border b) {
206 if (useUIBorder || b instanceof SynthBorder) {
207 super.setBorder(b);
208 }
209 }
210
211 @Override public Component getListCellRendererComponent(JList list, Object value,
212 int index, boolean isSelected, boolean cellHasFocus) {
213 if (!useListColors && (isSelected || cellHasFocus)) {
214 SynthLookAndFeel.setSelectedUI((SynthLabelUI)SynthLookAndFeel.
215 getUIOfType(getUI(), SynthLabelUI.class),
216 isSelected, cellHasFocus, list.isEnabled(), false);
217 }
218 else {
219 SynthLookAndFeel.resetSelectedUI();
|