/** * Gets the list cell renderer component. * * @param list the instance of JList * @param value the value object * @param index the index value * @param isSelected the boolean of isSelected * @param cellHasFocus the boolean of cellHasFocus */ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); IElementNode elementNode = (IElementNode) value; setText(elementNode.getText()); setIcon(elementNode.getIcon()); setToolTipText(elementNode.getToolTipText()); return this; }
/** * Gets the list cell renderer component. * * @param list the instance of JList * @param value the value object * @param index the index value * @param isSelected the boolean of isSelected * @param cellHasFocus the boolean of cellHasFocus */ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean hasFocus) { IElementNode elementNode = (IElementNode) value; checkBox.setSelected(elementNode.isSelected()); cellLabel.setText(elementNode.getText()); cellLabel.setIcon(elementNode.getIcon()); cellLabel.setToolTipText(elementNode.getToolTipText()); cellLabel.setSelected(isSelected); cellLabel.setFont(list.getFont()); cellLabel.setFocus(hasFocus); cellLabel.setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); cellLabel.setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); setToolTipText(elementNode.getToolTipText()); return this; }