| 1 19 package org.lucane.applications.reunion.ui; 20 21 import java.awt.Color ; 22 import java.awt.Component ; 23 24 import javax.swing.DefaultListCellRenderer ; 25 import javax.swing.JLabel ; 26 import javax.swing.JList ; 27 28 import org.lucane.applications.reunion.Reunion; 29 import org.lucane.applications.reunion.ReunionUserProperties; 30 31 class UserRenderer extends DefaultListCellRenderer  32 { 33 private Reunion plugin; 34 35 public UserRenderer(Reunion plugin) 36 { 37 this.plugin = plugin; 38 } 39 40 public Component getListCellRendererComponent(JList list, Object value, 41 int index, boolean isSelected, boolean cellHasFocus) 42 { 43 Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 44 JLabel label = (JLabel )c; 45 46 ReunionUserProperties props = (ReunionUserProperties)value; 47 48 String color = props.getFgColor().substring(1); 49 int red = Integer.parseInt(color.substring(0, 2), 16); 50 int green = Integer.parseInt(color.substring(2, 4), 16); 51 int blue = Integer.parseInt(color.substring(4, 6), 16); 52 53 54 label.setText(props.getUser()); 55 label.setForeground(new Color (red, green, blue)); 56 57 return label; 58 } 59 } | Popular Tags |