root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.gui / src / main / java / es / unex / sextante / gui / algorithm / LayerComboBoxRenderer.java @ 338
History | View | Annotate | Download (1.16 KB)
1 | 315 | omartinez | package es.unex.sextante.gui.algorithm; |
---|---|---|---|
2 | |||
3 | /*
|
||
4 | * To change this license header, choose License Headers in Project Properties.
|
||
5 | * To change this template file, choose Tools | Templates
|
||
6 | * and open the template in the editor.
|
||
7 | */
|
||
8 | import es.unex.sextante.core.ObjectAndDescription; |
||
9 | import java.awt.Component; |
||
10 | |||
11 | import javax.swing.DefaultListCellRenderer; |
||
12 | import javax.swing.Icon; |
||
13 | import javax.swing.JLabel; |
||
14 | import javax.swing.JList; |
||
15 | import javax.swing.ListCellRenderer; |
||
16 | |||
17 | public class LayerComboBoxRenderer implements ListCellRenderer { |
||
18 | protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer(); |
||
19 | |||
20 | public Component getListCellRendererComponent(JList list, Object value, int index, |
||
21 | boolean isSelected, boolean cellHasFocus) { |
||
22 | |||
23 | JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, |
||
24 | isSelected, cellHasFocus); |
||
25 | |||
26 | if (value instanceof ObjectAndDescription) { |
||
27 | ObjectAndDescription v = (ObjectAndDescription) value; |
||
28 | |||
29 | Icon theIcon = v.getIcon();
|
||
30 | String name = v.getDescription();
|
||
31 | |||
32 | renderer.setIcon(theIcon); |
||
33 | renderer.setText(name); |
||
34 | } |
||
35 | return renderer;
|
||
36 | } |
||
37 | } |