javax.swing.JList#getSelectionForeground ( )源码实例Demo

下面列出了javax.swing.JList#getSelectionForeground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: FixProfile.java
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();
}
 
源代码2 项目: netbeans   文件: TreeList.java
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);
}
 
源代码3 项目: netbeans   文件: SelectionList.java
@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);
}
 
源代码4 项目: netbeans   文件: RemoveSurroundingCodePanel.java
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();
}
 
源代码5 项目: netbeans   文件: ImportClassPanel.java
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();        
}
 
源代码6 项目: netbeans   文件: RunAsRemoteWeb.java
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();
}
 
源代码7 项目: netbeans   文件: ImportModulePanel.java
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();
}
 
源代码8 项目: netbeans   文件: GenerateCodePanel.java
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();
}
 
源代码9 项目: wpcleaner   文件: PageListCellRenderer.java
@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;
}