@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 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; }
/** * 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; }
@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; }
/** * Paint the arrow in the panel, using the current style. * * @param g the graphic context. */ public void paintComponent(Graphics g) { g.setColor(isSelected ? list.getSelectionBackground() : list.getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(isSelected ? list.getSelectionForeground() : list.getForeground()); g.drawLine(getWidth() / 3, getHeight() / 2, 2 * getWidth() / 3, getHeight() / 2); Arrow arrowDummy = new Arrow(); arrowDummy.drawArrowPixels( new Graphics2DSwing(g), getWidth() / 3, getHeight() / 2, 2 * getWidth() / 3, getHeight() / 2, 10, 4, arrow.style); }
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()); } if (value instanceof ConfigParamDescr) { ConfigParamDescr descr = (ConfigParamDescr) value; setText(descr.getDisplayName()); } else { setText(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.index = index; if (isSelected) { setBackground(list.getSelectionBackground()); label.setForeground(list.getSelectionForeground()); } else { setBackground(index % 2 == 0 ? EVEN_COLOR : list.getBackground()); label.setForeground(list.getForeground()); } resetButtonStatus(); if (Objects.nonNull(button)) { if (index == pressedIndex) { button.getModel().setSelected(true); button.getModel().setArmed(true); button.getModel().setPressed(true); } else if (index == rolloverIndex) { button.getModel().setRollover(true); } } return this; }