/** {@inheritDoc} */ @Override public Component getListCellRendererComponent( JList list, final Object value, final int index, boolean isSelected, final boolean cellHasFocus) { Component label = getObjectComponent(list, value, index, isSelected, cellHasFocus); if (label instanceof JComponent) ((JComponent) label).setOpaque(false); panel.removeAll(); panel.add(label); panel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); panel.restoreBackground(); if (cellHasFocus) if (panel.isBackgroundRestored()) panel.setBackground(UIUtils.setAlpha(list.getSelectionBackground(), 100)); else panel.setBorder(BorderFactory.createLineBorder(list.getSelectionBackground())); if (isSelected) if (panel.isBackgroundRestored()) panel.setBackground(UIUtils.setAlpha(list.getSelectionBackground(), 200)); else panel.setBorder(BorderFactory.createLineBorder(list.getSelectionBackground())); if (index == hoveredIndex) panel.mouseEntered(null); return panel; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Object[] values = (Object[]) list.getModel().getElementAt(index); String icoState = (String) (values[0]); setIcon(null); if (icoState.equals("bad")) { // Error setIcon(errIco); setBackground(list.getSelectionForeground()); // RED setForeground(Color.BLACK); setBorder(BorderFactory.createLineBorder(Color.BLUE, 1)); } else if (icoState.equals("good")) { // Ok setIcon(nrmIco); setBackground(list.getSelectionBackground()); // GREEN setForeground(Color.BLACK); setBorder(BorderFactory.createLineBorder(Color.BLUE, 1)); } else if (icoState.equals("goodcont")) { // Ok setIcon(imdIco); setBackground(list.getSelectionBackground()); // GREEN setForeground(Color.BLACK); setBorder(BorderFactory.createLineBorder(list.getSelectionBackground(), 1)); } else { setIcon(ibdIco); // Errorcont setBackground(list.getSelectionForeground()); // RED setForeground(Color.BLACK); setBorder(BorderFactory.createLineBorder(list.getSelectionForeground(), 1)); } setText((String) (values[1])); setFont(list.getFont()); return this; }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); } else { setBackground(Color.WHITE); } if (colors.length != strings.length) { System.out.println("colors.length does not equal strings.length"); return this; } else if (colors == null) { System.out.println("use setColors first."); return this; } else if (strings == null) { System.out.println("use setStrings first."); return this; } text.setBackground(getBackground()); text.setText(value.toString()); if (index > -1) { text.setForeground(colors[index]); } return text; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // #93658: GTK needs name to render cell renderer "natively" setName("ComboBox.listRenderer"); // NOI18N String config = (String) value; String label; if (config == null) { // uninitialized? label = null; } else if (config.length() > 0) { Map<String, String> m = configs.get(config); label = m != null ? m.get("$label") : /* temporary? */ null; // NOI18N if (label == null) { label = config; } } else { label = NbBundle.getBundle("org.netbeans.modules.java.j2seproject.Bundle") .getString("J2SEConfigurationProvider.default.label"); // NOI18N } setText(label); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof StoryComponentPanel) { final StoryComponentPanel valuePanel; final StoryComponent valueComponent; final Boolean isVisible; valuePanel = (StoryComponentPanel) value; valueComponent = valuePanel.getStoryComponent(); isVisible = valueComponent.isVisible(); valuePanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY)); if (isVisible && valueComponent.getLibrary().isReadOnly() && !isSelected && SEModelManager.getInstance().getActiveModel() instanceof LibraryModel && !ScriptEase.DEBUG_MODE) valuePanel.setBackground(ScriptEaseUI.TERTIARY_UI); else if (isSelected && isVisible) valuePanel.setBackground(list.getSelectionBackground()); else if (isSelected && !isVisible) valuePanel.setBackground(ScriptEaseUI.SELECTED_COLOUR); else if (!isSelected && !isVisible) valuePanel.setBackground(Color.DARK_GRAY); else if (!isSelected && isVisible) valuePanel.setBackground(list.getBackground()); if (valueComponent instanceof CauseIt || valueComponent instanceof ActivityIt) { valuePanel.setShowChildren(false); valuePanel.getExpansionButton().setCollapsed(true); } return valuePanel; } else if (value instanceof JPanel) { return (JPanel) value; } else return new JLabel("Error: Not a story component: " + value.toString()); }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { /** * if (isSelected) { setBackground(UIManager.getColor("ComboBox.selectionBackground")); * setForeground(UIManager.getColor("ComboBox.selectionForeground")); } else { * setBackground(UIManager.getColor("ComboBox.background")); * setForeground(UIManager.getColor("ComboBox.foreground")); }* */ if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setFont(list.getFont()); if (value instanceof Icon) { setIcon((Icon) value); } else { setText((value == null) ? "" : value.toString()); } return this; }
@Override public Component getListCellRendererComponent( JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) { label.setText(Objects.toString(value, "")); this.list = list; this.index = index; if (isSelected) { setBackground(list.getSelectionBackground()); label.setForeground(list.getSelectionForeground()); } else { setBackground(index % 2 == 0 ? EVEN_COLOR : list.getBackground()); label.setForeground(list.getForeground()); } MutableComboBoxModel m = (MutableComboBoxModel) list.getModel(); if (index < 0 || m.getSize() - 1 <= 0) { setOpaque(false); deleteButton.setVisible(false); label.setForeground(list.getForeground()); } else { boolean f = index == rolloverIndex; setOpaque(true); deleteButton.setVisible(true); deleteButton.getModel().setRollover(f); deleteButton.setForeground(f ? Color.WHITE : list.getForeground()); } return this; }
public java.awt.Component getListCellRendererComponent( javax.swing.JList list, Object color, int index, boolean isSelected, boolean cellHasFocus) { return getComponent( color, isSelected, list.getBackground(), list.getSelectionBackground(), list.getFixedCellHeight(), list.getFont()); }
@Override protected void fillPage( final Page page, JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Color foreground = isSelected ? list.getSelectionForeground() : list.getForeground(); Color background = isSelected ? list.getSelectionBackground() : list.getBackground(); renderCellValue(page, value, foreground, background, isSelected); }
public Renderer(JList list) { setFont(list.getFont()); fgColor = list.getForeground(); bgColor = list.getBackground(); bgColorDarker = new Color( Math.abs(bgColor.getRed() - DARKER_COLOR_COMPONENT), Math.abs(bgColor.getGreen() - DARKER_COLOR_COMPONENT), Math.abs(bgColor.getBlue() - DARKER_COLOR_COMPONENT)); bgSelectionColor = list.getSelectionBackground(); fgSelectionColor = list.getSelectionForeground(); }
@SuppressWarnings("rawtypes") @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value != null) { FBUser user = (FBUser) value; setText(user.getName()); } setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); return this; }
/** * Return a component that has been configured to display the specified value. * * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, Object, * int, boolean, boolean) */ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final String key = (String) value; final Icon icon = IconSource.getIcon(key); final Color back = isSelected ? list.getSelectionBackground() : list.getBackground(); setBackground(back); iconLabel.setBackground(back); iconLabel.setIcon(icon); return this; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); setFont(list.getFont()); setBorder( (cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : m_noFocusBorder); return this; }
/* * This method finds the image and text corresponding * to the selected value and returns the label, set up * to display the text and image. */ @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean hasFocus) { setEnabled(list.isEnabled()); setSelected(((CheckListItem) value).isSelected()); setFont(list.getFont()); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setText(value.toString()); return this; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } ImageIcon icon = (ImageIcon) value; setText(icon.getDescription()); setIcon(icon); return this; }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String key = (String) value; if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setText(key); setIcon(content.get(key)); setFont(list.getFont()); 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; }
/* * This method finds the image and text corresponding * to the selected value and returns the label, set up * to display the text and image. */ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // Get the selected index. (The index param isn't // always valid, so just use the value.) if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); // setBorder(BorderFactory.createLineBorder(Color.red,2)); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setHorizontalAlignment(LEFT); setText(((App) value).getNombre()); return this; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Testable testCase = (Testable) value; setText(testName(testCase)); setOpaque(true); setIcon(testCase.isPassed() ? tickIcon : (testCase.isFailed() ? crossIcon : clearIcon)); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setEnabled(list.isEnabled()); setFont(list.getFont()); return this; }
public Component getListCellRendererComponent( JList<? extends String> list, String value, int index, boolean isSelected, boolean cellHasFocus) { setIcon(getIcon(value, parser)); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setEnabled(list.isEnabled()); return this; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String s = value.toString(); setText(s); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setEnabled(list.isEnabled()); setFont(list.getFont()); setOpaque(true); setToolTipText(((StyleSourceInfo) value).getTooltip()); return this; }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { XmlElementDescriptor descriptor = (XmlElementDescriptor) value; Color backgroundColor = isSelected ? list.getSelectionBackground() : list.getBackground(); myNameLabel.setText(descriptor.getName()); myNameLabel.setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); myPanel.setBackground(backgroundColor); myNSLabel.setText(getNamespace(descriptor)); myNSLabel.setForeground(LookupCellRenderer.getGrayedForeground(isSelected)); myNSLabel.setBackground(backgroundColor); return myPanel; }
/** {@inheritDoc} */ @Override public Component getListCellRendererComponent( JList<? extends String> list, String value, int index, boolean isSelected, boolean cellHasFocus) { FreeColGameObject fcgo = getGame().getFreeColGameObject(value); if (fcgo instanceof Location) { setText(Messages.message(((Location) fcgo).getLocationLabel())); } else { setText(value); } setForeground((isSelected) ? list.getSelectionForeground() : list.getForeground()); setBackground((isSelected) ? list.getSelectionBackground() : list.getBackground()); return this; }
public Component getListCellRendererComponent( JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value != null) { Integer num = (Integer) value; setText(cm.NameMap.get(num)); setIcon(new ImageIcon(cm.IconMap.get(num))); } if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { // 设置选取与取消选取的前景与背景颜色. setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setText(" " + ((JmolInstance) value).name); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setEnabled(list.isEnabled()); setFont(list.getFont()); setOpaque(true); enableButtons(list); return this; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value != null) { panel.setTodoItem((TodoItem) value); } if (isSelected) { adjustColors(list.getSelectionBackground(), list.getSelectionForeground()); } else { adjustColors(list.getBackground(), list.getForeground()); if ((index % 2) == 0) { panel.setBackground(STRIPE_COLOR); adjustColors(STRIPE_COLOR, list.getForeground()); } } return panel; }
/** Implement this method in ListCellRenderer */ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Object[] pair = (Object[]) value; // Cast value into an array jlblCell.setOpaque(true); jlblCell.setIcon((ImageIcon) pair[0]); jlblCell.setText(pair[1].toString()); if (isSelected) { jlblCell.setForeground(list.getSelectionForeground()); jlblCell.setBackground(list.getSelectionBackground()); } else { jlblCell.setForeground(list.getForeground()); jlblCell.setBackground(list.getBackground()); } jlblCell.setBorder(cellHasFocus ? lineBorder : emptyBorder); return jlblCell; }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String str = (value == null) ? null : value.toString(); if (Utils.SEPARATOR.equals(str)) { return separator; } if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setFont(list.getFont()); setText(str); updateHeight(); return this; }
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // int selectedIndex = ((Integer)value).intValue(); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } if (value != null) { setIcon((ImageIcon) value); } return this; }