2 * ComboBoxURLItemRenderer.java
\r
4 * Created on 09 November 2001, 21:07
\r
5 * $Header: /VisTA/CID/ComboBoxURLItemRenderer.java 2 10/11/01 0:53 Tj $
\r
7 * $History: ComboBoxURLItemRenderer.java $
\r
9 * ***************** Version 2 *****************
\r
10 * User: Tj Date: 10/11/01 Time: 0:53
\r
11 * Updated in $/VisTA/CID
\r
15 package org.tjworld.components;
\r
17 import java.awt.Component;
\r
18 import javax.swing.JList;
\r
21 * Renders URL document titles and icons as simple JLabels for JComboBox
\r
24 * @version 1.0 10 Nov, 2001
\r
26 public class ComboBoxURLItemRenderer extends javax.swing.JLabel implements javax.swing.ListCellRenderer {
\r
28 /** Creates new ComboBoxURLItemRenderer */
\r
29 public ComboBoxURLItemRenderer() {
\r
31 setVerticalAlignment(CENTER);
\r
32 setHorizontalAlignment(LEADING);
\r
36 * Return a component that has been configured to display the specified
\r
37 * value. That component's <code>paint</code> method is then called to
\r
38 * "render" the cell. If it is necessary to compute the dimensions
\r
39 * of a list because the list cells do not have a fixed size, this method
\r
40 * is called to generate a component on which <code>getPreferredSize</code>
\r
43 * @param list The JList we're painting.
\r
44 * @param value The value returned by list.getModel().getElementAt(index).
\r
45 * @param index The cells index.
\r
46 * @param isSelected True if the specified cell was selected.
\r
47 * @param cellHasFocus True if the specified cell has the focus.
\r
48 * @return A component whose paint() method will render the specified value.
\r
51 * @see ListSelectionModel
\r
54 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
\r
56 setBackground(list.getSelectionBackground());
\r
57 setForeground(list.getSelectionForeground());
\r
59 setBackground(list.getBackground());
\r
60 setForeground(list.getForeground());
\r
63 ComboBoxURLItem cbItem = (ComboBoxURLItem)value;
\r
64 setText(cbItem.getTitle());
\r
65 setIcon(cbItem.getIcon());
\r