1 7 package com.sun.java.swing.plaf.motif; 8 9 15 16 import javax.swing.*; 17 import javax.swing.event.*; 18 import javax.swing.border.*; 19 20 import java.awt.Component ; 21 import java.awt.Color ; 22 23 import java.io.Serializable ; 24 25 35 public class MotifComboBoxRenderer extends JLabel 36 implements ListCellRenderer, Serializable 37 { 38 protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); 39 40 public MotifComboBoxRenderer() { 41 super(); 42 setOpaque(true); 43 setBorder(noFocusBorder); 44 } 45 46 47 public Component getListCellRendererComponent( 48 JList list, 49 Object value, 50 int index, 51 boolean isSelected, 52 boolean cellHasFocus) 53 { 54 55 setHorizontalAlignment(SwingConstants.LEFT); 56 if (isSelected) { 57 setBackground(list.getSelectionBackground()); 58 setForeground(list.getSelectionForeground()); 59 } else { 60 setBackground(list.getBackground()); 61 setForeground(list.getForeground()); 62 } 63 64 if (value instanceof Icon) { 65 setIcon((Icon)value); 66 } 67 else { 68 setText((value == null) ? "" : value.toString()); 69 } 70 return this; 71 } 72 73 74 87 public static class UIResource extends MotifComboBoxRenderer 88 implements javax.swing.plaf.UIResource 89 { 90 } 91 92 93 94 } 95 96 97 | Popular Tags |