svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / comboboxconfigurablelookup / programmertests / SampleBasicComboBoxRenderer.java @ 40561
History | View | Annotate | Download (2.23 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.gui.beans.comboboxconfigurablelookup.programmertests; |
25 |
|
26 |
import java.awt.Color; |
27 |
import java.awt.Component; |
28 |
|
29 |
import javax.swing.JList; |
30 |
import javax.swing.plaf.basic.BasicComboBoxRenderer; |
31 |
|
32 |
/**
|
33 |
* <p>Sample of personalized combo box cell renderer.</p>
|
34 |
*
|
35 |
* @version 08/02/2008
|
36 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
37 |
*/
|
38 |
public class SampleBasicComboBoxRenderer extends BasicComboBoxRenderer { |
39 |
private static final long serialVersionUID = -9044759678425798655L; |
40 |
|
41 |
/**
|
42 |
* <p>Creates a new instance of the <code>SampleBasicComboBoxRenderer</code> class.</p>
|
43 |
*/
|
44 |
public SampleBasicComboBoxRenderer() {
|
45 |
super();
|
46 |
} |
47 |
|
48 |
/*
|
49 |
* (non-Javadoc)
|
50 |
* @see javax.swing.plaf.basic.BasicComboBoxRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
|
51 |
*/
|
52 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
53 |
Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
54 |
|
55 |
if (isSelected)
|
56 |
component.setBackground(Color.GRAY);
|
57 |
else
|
58 |
component.setBackground(new Color(((17 * index) % 256), ((31 * index) % 256), ((7 * index) % 256))); |
59 |
|
60 |
return component;
|
61 |
} |
62 |
} |