public Component getListCellRendererComponent( JList list, Object value, // value // to // display int index, // cell index boolean isSelected, // is the cell selected boolean cellHasFocus) // the list and the cell have the focus { String s = value.toString(); setText(s); setForeground(list.getForeground()); String name = listItems.get(index); if (selected.contains(name)) { if (users.contains(name)) setBackground(Color.GREEN); else setBackground(Color.YELLOW); } else { setBackground(list.getBackground()); } setEnabled(list.isEnabled()); setFont(list.getFont()); setOpaque(true); 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; }
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; }
@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()); }
protected void paintComponent(Graphics g) { // Set up rendering hints to look as close to native as possible Graphics2D g2d = (Graphics2D) g; Object old = null; // First, try to use the rendering hint set that is "native". Map hints = (Map) getToolkit().getDesktopProperty("awt.font.desktophints"); if (hints != null) { old = g2d.getRenderingHints(); g2d.addRenderingHints(hints); } // If a "native" set isn't found, just turn on standard text AA. else { old = g2d.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); g2d.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } // if (jsc!=null) { // setText(null); // Stop "Foobar" from being painted // } // We never paint "selection" around the icon, to imitate Eclipse final int iconW = 18; int h = getHeight(); if (!selected) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), h); } else { g.setColor(altBG != null && evenRow ? altBG : list.getBackground()); g.fillRect(0, 0, iconW, h); g.setColor(getBackground()); // Selection color g.fillRect(iconW, 0, getWidth() - iconW, h); } if (getIcon() != null) { int y = (h - getIcon().getIconHeight()) / 2; getIcon().paintIcon(this, g, 0, y); } int x = getX() + iconW + 2; g.setColor(selected ? list.getSelectionForeground() : list.getForeground()); if (jsc != null && !simpleText) { jsc.rendererText(g, x, g.getFontMetrics().getHeight(), selected); } else { Completion c = jsc != null ? (Completion) jsc : nonJavaCompletion; if (c != null) { g.drawString(c.toString(), x, g.getFontMetrics().getHeight()); } } // Restore rendering hints appropriately. if (hints != null) { g2d.addRenderingHints((Map) old); } else { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, old); } }
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; }
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.) int selectedIndex = ((Integer) value).intValue(); this.id = selectedIndex; if (isSelected) { setBackground(Color.LIGHT_GRAY); // setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); // setForeground(list.getForeground()); } setBorder(BorderFactory.createEmptyBorder(12, 2, 12, 2)); 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; }
@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; }
/** * 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; }
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; }
/* * 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; }
/** {@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) { 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; }
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) { 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; }
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; }
/** 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; }