Java Code Examples for javax.swing.JList#getSelectionForeground()

The following examples show how to use javax.swing.JList#getSelectionForeground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FixProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
LibsRenderer(@NonNull final JList list) {
    this.root = new JLabel();
    this.root.setHorizontalAlignment(LEFT);
    this.root.setOpaque(false);
    this.root.setFont(list.getFont());
    this.profile = new JLabel();
    this.profile.setHorizontalAlignment(RIGHT);
    this.profile.setOpaque(false);
    this.profile.setFont(list.getFont());
    this.container = new JPanel();
    this.container.setLayout(new BorderLayout());
    this.container.add (this.root, BorderLayout.WEST);
    this.container.add (this.profile, BorderLayout.EAST);
    
    fgColor = list.getForeground();
    fgColorLighter = new Color(
        Math.min(255, fgColor.getRed() + LIGHTER_COLOR_COMPONENT),
        Math.min(255, fgColor.getGreen() + LIGHTER_COLOR_COMPONENT),
        Math.min(255, fgColor.getBlue() + LIGHTER_COLOR_COMPONENT));
    bgColor = new Color(list.getBackground().getRGB());
    bgSelectionColor = list.getSelectionBackground();
    fgSelectionColor = list.getSelectionForeground();
}
 
Example 2
Source File: TreeList.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    if (!(value instanceof TreeListNode)) {
        //shoudln't happen
        return new JLabel();
    }
    TreeListNode node = (TreeListNode) value;
    int rowHeight = list.getFixedCellHeight();
    int rowWidth = list.getVisibleRect().width;
    int dropIndex = -1;
    DropLocation dropLocation = list.getDropLocation();
    if (dropLocation != null && !dropLocation.isInsert()) {
        dropIndex = dropLocation.getIndex();
    }
    boolean isDropTarget = dropIndex == index;
    isSelected = isSelected || isDropTarget;
    Color background = isSelected ? list.getSelectionBackground() : list.getBackground();
    Color foreground = isSelected ? list.getSelectionForeground() : list.getForeground();

    return node.getRenderer(foreground, background, isSelected, cellHasFocus, rowHeight, rowWidth);
}
 
Example 3
Source File: SelectionList.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent( JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus ) {
    if (!(value instanceof ListNode)) {
        //shoudln't happen
        return new JLabel();
    }
    if( list instanceof SelectionList ) {
        isSelected |= index == ((SelectionList)list).getMouseOverRow();
    }
    ListNode node = (ListNode) value;
    int rowHeight = list.getFixedCellHeight();
    int rowWidth = list.getWidth();
    JScrollPane scroll = ( JScrollPane ) SwingUtilities.getAncestorOfClass( JScrollPane.class, list);
    if( null != scroll )
        rowWidth = scroll.getViewport().getWidth();
    Color background = isSelected ? list.getSelectionBackground() : list.getBackground();
    Color foreground = isSelected ? list.getSelectionForeground() : list.getForeground();

    return node.getListRenderer(foreground, background, isSelected, cellHasFocus, rowHeight, rowWidth);
}
 
Example 4
Source File: RemoveSurroundingCodePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 5
Source File: ImportClassPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();        
}
 
Example 6
Source File: RunAsRemoteWeb.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Color getForeground(RemoteConfiguration remoteConfig, JList list, boolean isSelected) {
    if (remoteConfig == RunConfigRemote.MISSING_REMOTE_CONFIGURATION
            || remoteConfig == RunConfigRemote.NO_REMOTE_CONFIGURATION) {
        return UIManager.getColor("nb.errorForeground"); // NOI18N
    }
    return isSelected ? list.getSelectionForeground() : list.getForeground();
}
 
Example 7
Source File: ImportModulePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 8
Source File: GenerateCodePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 9
Source File: PageListCellRenderer.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
@Override
public Component getListCellRendererComponent(
    JList<? extends Page> list,
    Page value,
    @SuppressWarnings("unused") int index,
    boolean isSelected,
    @SuppressWarnings("unused") boolean cellHasFocus) {

  // Retrieve data
  String pageName = (value != null) ? value.toString() : "";
  String text = pageName;
  Boolean disambiguation = null;
  Boolean exist = null;
  boolean redirect = false;
  InternalLinkCount count = null;
  if (value != null) {
    Page pageElement = value;
    pageName = pageElement.getTitle();
    text = pageName;
    disambiguation = pageElement.isDisambiguationPage();
    exist = pageElement.isExisting();
    count = (analysis != null) ? analysis.getLinkCount(pageElement) : null;
    if (showCountOccurrence &&
        (count != null) &&
        (count.getTotalLinkCount() > 0)) {
      text += " → " + count.getTotalLinkCount(); 
    }
    redirect = pageElement.getRedirects().isRedirect();
    if (redirect && showRedirectBacklinks) {
      Integer backlinks = pageElement.getBacklinksCountInMainNamespace();
      if ((backlinks != null) && (backlinks.intValue() > 0)) {
        text += " ← " + backlinks;
      }
    }
  }

  // Text
  setText(text);

  // Color
  Color background = isSelected ? list.getSelectionBackground() : Color.WHITE;
  Color foreground = isSelected ? list.getSelectionForeground() : list.getForeground();
  if (showDisambiguation) {
    if (disambiguation == null) {
      if (!isSelected) {
        foreground = Color.DARK_GRAY;
      }
    } else if (disambiguation.booleanValue()) {
      if (count == null) {
        foreground = Color.RED;
      } else if ((count.getInternalLinkCount() > 0) || (count.getIncorrectTemplateCount() > 0)) {
        foreground = Color.RED;
      } else if ((count.getHelpNeededCount() > 0)) {
        foreground = Color.ORANGE;
      } else {
        foreground = Color.BLUE;
      }
    }
  } else if (pageProperties != null) {
    String property = pageProperties.getProperty(pageName);
    if (Configuration.VALUE_PAGE_NORMAL.equals(property)) {
      foreground = Color.GREEN;
    } else if (Configuration.VALUE_PAGE_HELP_NEEDED.equals(property)) {
      foreground = Color.ORANGE;
    }
  }
  setBackground(background);
  setForeground(foreground);

  // Font
  if (showMissing && Boolean.FALSE.equals(exist)) {
    setFont(missingFont);
  } else if (showRedirect && redirect) {
    setFont(redirectFont);
  } else {
    setFont(normalFont);
  }

  return this;
}