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

下面列出了javax.swing.JList#getForeground ( ) 实例代码,或者点击链接到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   文件: AuthenticationSettingsPanel.java
@Override
public Component getListCellRendererComponent(JList<? extends AuthenticationCheckboxListItem> list, AuthenticationCheckboxListItem value,
        int index, boolean isSelected, boolean cellHasFocus) {
    final Color bc;
    final Color fc;
    if (isSelected) {
        bc = UIManager.getColor("List.selectionBackground"); //NOI18N
        fc = UIManager.getColor("List.selectionForeground"); //NOI18N
    } else {
        bc = list.getBackground();
        fc = list.getForeground();
    }
    setBackground(bc); // NOI18N
    setForeground(fc); // NOI18N
    
    label.setBackground(bc);
    label.setForeground(fc);
    label.setText(value.getDisplayName());
    label.setFont(list.getFont());
    
    check.setSelected(value.isSelected());
    check.setBackground(bc);
    check.setForeground(fc);
    check.setEnabled(list.isEnabled());
    
    Border border;
    if (cellHasFocus) {
        border = focusBorder;
    } else {
        border = noFocusBorder;
    }
    setBorder(border);
    
    return this;
}
 
源代码9 项目: 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();
}
 
源代码10 项目: netbeans   文件: ConfigurationRenderer.java
@Override
public Component getListCellRendererComponent(
        JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
    
    if (value != null) {
        if (value instanceof Configuration) {
            setText(((Configuration) value).getDisplayName());
        } else {
            setText(value.toString());
        }
    }

    if (!bordersInitialized) {
        //#222894: the original border must be kept for GTK
        originalBorder = getBorder();
        Separator separator = new Separator(list.getForeground());
        if (originalBorder != null) separatorBorder = new CompoundBorder(originalBorder, separator);
        else separatorBorder = separator;
        bordersInitialized = true;
    }
    
    if (index == list.getModel().getSize()-5 && ((ConfigurationsComboModel) list.getModel()).canModify() ) {
        setBorder(separatorBorder);
    } else {
        setBorder(originalBorder);
    }
    
    if (isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());
    } else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());
    }

    // #89393: GTK needs name to render cell renderer "natively"
    setName("ComboBox.listRenderer"); // NOI18N
    return this;
}
 
源代码11 项目: 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;
}
 
源代码12 项目: wpcleaner   文件: CheckErrorPageListCellRenderer.java
@Override
public Component getListCellRendererComponent(
    JList<? extends CheckErrorPage> list,
    CheckErrorPage value,
    @SuppressWarnings("unused") int index,
    boolean isSelected,
    @SuppressWarnings("unused") boolean cellHasFocus) {

  // Retrieve data
  String text = (value != null) ? value.toString() : "";
  Boolean errorsPresent = null;
  Boolean globalFix = null;
  boolean whiteList = false;
  if (value != null) {
    CheckErrorPage errorPage = value;
    whiteList = errorPage.isInWhiteList();
    if (forPage && (errorPage.getPage() != null)) {
      text = errorPage.getPage().getTitle();
    } else {
      text = errorPage.getAlgorithm().toString();
      int errorCount = errorPage.getActiveResultsCount();
      if (errorCount > 0) {
        errorsPresent = Boolean.TRUE;
        if ((showCountOccurence) &&
            (errorCount > 1)) {
          text += " (" + errorCount + ")";
        }
      } else if (errorPage.getErrorFound()) {
        errorsPresent = Boolean.TRUE;
      } else {
        errorsPresent = Boolean.FALSE;
      }
      String[] globalFixes = errorPage.getAlgorithm().getGlobalFixes();
      if ((globalFixes != null) && (globalFixes.length > 0)) {
        globalFix = Boolean.TRUE;
      }
    }
  }

  // Text
  setText(text);
  if (Boolean.TRUE.equals(globalFix)) {
    setIcon(globalFixIcon);
  } else {
    setIcon(null);
  }

  // Color
  Color background = isSelected ? new Color(230, 230, 230) : Color.WHITE;
  Color foreground = list.getForeground();
  if (forPage) {
    if (whiteList) {
      foreground = Color.GREEN;
    }
  } else if (errorsPresent == null) {
    if (!isSelected) {
      foreground = Color.DARK_GRAY;
    }
  } else if (whiteList) {
    foreground = Color.GREEN;
  } else if (errorsPresent.booleanValue()) {
    foreground = Color.RED;
  }
  setBackground(background);
  setForeground(foreground);

  return this;
}