setEnabled(list.isEnabled()); setFont(list.getFont());
if (value instanceof Icon) setIcon((Icon) value); else setText(value == null ? "" : value.toString());
  public Component getListCellRendererComponent(JList list, Object value,                                                int index, boolean isSelected,                                                boolean cellHasFocus)  {    String s = value.toString();        // String maybe larger than comboBox.    FontMetrics fm = getToolkit().getFontMetrics(list.getFont());    int strWidth = SwingUtilities.computeStringWidth(fm, s);    int cbWidth = getSize().width;    if (cbWidth != 0 && strWidth > cbWidth)      {        char[] str = s.toCharArray();        int currWidth = 0;        int i = 0;        String postStr = "... ";        cbWidth -= SwingUtilities.computeStringWidth(fm, postStr);        while (i < str.length && currWidth < cbWidth)          {            ++i;            currWidth = SwingUtilities.computeStringWidth(fm, new String(str, 0, i));          }        setText(new String(str, 0, i)  + postStr);      }    else         setText(s);        setOpaque(true);    if (isSelected || cellHasFocus)      {        setBackground(list.getSelectionBackground());        setForeground(list.getSelectionForeground());      }    else      {        setBackground(list.getBackground());        setForeground(list.getForeground());      }    setEnabled(list.isEnabled());    setFont(list.getFont());    return this;  }