当前位置: 首页>>代码示例>>Java>>正文


Java Component.setForeground方法代码示例

本文整理汇总了Java中java.awt.Component.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java Component.setForeground方法的具体用法?Java Component.setForeground怎么用?Java Component.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Component的用法示例。


在下文中一共展示了Component.setForeground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTableCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
    boolean hasFocus, int row, int col) {
  Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
      col);

  String fullKey = target.getI18nData().getFullPrefix() + keys[row]; //$NON-NLS-1$
  String translation = currentTranslation == null ? "" : currentTranslation.translate(fullKey);
  String originalValue = target.getAttributeValueString(keys[row]);

  if (originalValue == null || originalValue.length() == 0) {
    c.setForeground(NO_TRANSLATION_NEEDED_COLOR);
  }
  else {
    if (translation == null || translation.length() == 0) {
      c.setForeground(TRANSLATION_NEEDED_COLOR);
    }
    else {
      c.setForeground(TRANSLATION_DONE_COLOR);
    }
  }

  return c;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:24,代码来源:TranslateWindow.java

示例2: getTableCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent( JTable   table,
                                                Object   value,
                                                boolean  isSelected,
                                                boolean  hasFocus,
                                                int      rowIndex,
                                                int      columnIndex )
{
    MergeTableModel  model = (MergeTableModel) table.getModel();
    String  leftProperty = propertyOn( model.leftLineAtRow(rowIndex) );
    String  rightProperty = propertyOn( model.rightLineAtRow(rowIndex) );
    boolean  same = leftProperty.equals( rightProperty );
    Component  c = super.getTableCellRendererComponent( table,
                                                        value,
                                                        isSelected,
                                                        hasFocus,
                                                        rowIndex,
                                                        columnIndex );
    c.setForeground( same ? Color.BLACK : Color.RED );
    return c;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:22,代码来源:MergeTableCellRenderer.java

示例3: getTreeCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    PackageNode item = (PackageNode) value;

    if (hasFocus) {
	item.updateHelp(help, true);
    }

    Component defaultC = defaultR.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    if (item.isDisabled()) {
	defaultC.setForeground(disabledColor);
    }

    if (item.type == PackageNode.Type.VARSET && ((VariantSet)item).spec == null) {
	defaultC.setForeground(Color.RED);
    }

    return defaultC;
}
 
开发者ID:tstavrianos,项目名称:automatic-variants,代码行数:20,代码来源:PackageTree.java

示例4: prepareRenderer

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component c = super.prepareRenderer(renderer, row, column);
    if (getModel().hasUpdates(
            convertRowIndexToModel(row),
            convertColumnIndexToModel(column))) {
        
        Color color = isCellSelected(row, column) ? selectedForeground : unselectedForeground;
        
        if (c instanceof JCheckBox) {
            checkboxReplacement.removeAll();
            checkboxReplacement.setBorder(new LineBorder(color, borderThickness));
            checkboxReplacement.add(c);
            return checkboxReplacement;
        } else {
            c.setForeground(color);
            return c;
        }
    }
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:DataViewTableUI.java

示例5: getCellRenderer

import java.awt.Component; //导入方法依赖的package包/类
/**
 * The original getCellRenderer method is overwritten, since the table
 * displays in red the values of the selected class
 * @param row the row of the cell
 * @param column the column of the cell
 * @return a the TableCellRenderer for the requested cell (row,column)
 */
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
	dtcr.setHorizontalAlignment(SwingConstants.CENTER);
	Component c;
	if (column < cd.getClosedClassKeys().size()) {
		Vector<Object> closedClasses = cd.getClosedClassKeys();
		Object thisClass = closedClasses.get(column);
		int thisPop = cd.getClassPopulation(thisClass).intValue();
		c = dtcr.getTableCellRendererComponent(this, Integer.toString(thisPop), false, false, row, column);
		if (NCPA.isSingleClass()) {
			if (thisClass == NCPA.getReferenceClass()) {
				c.setForeground(Color.RED);
			} else {
				c.setForeground(Color.BLACK);
			}
		} else {
			c.setForeground(Color.RED);
		}
	} else {
		c = dtcr.getTableCellRendererComponent(this, "-", false, false, row, column);
		c.setForeground(Color.BLACK);
	}
	((JLabel) c).setToolTipText(cd.getClassName(cd.getClosedClassKeys().get(column)));
	return dtcr;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:33,代码来源:NumberOfCustomersPanel.java

示例6: getCellRenderer

import java.awt.Component; //导入方法依赖的package包/类
/**
 * The original getCellRenderer method is overwritten, since the table
 * displays in red the values that could not be calculated with the requested
 * precision
 * @param row the row of the cell
 * @param column the column of the cell
 * @return a the TableCellRenderer for the requested cell (row,column)
 */
public TableCellRenderer getCellRenderer(int row, int column) {
	dtcr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
	//Component c = null;
	Component c;
	if (column < values.size()) {
		c = dtcr.getTableCellRendererComponent(this, values.get(column), false, false, row, column);
		//if (!((Boolean)(validities.get(column))).booleanValue()) {
		if (!((PAResultsModel.MeasureValueImpl) values.get(column)).isValid()) {
			c.setForeground(Color.RED);
		} else {
			c.setForeground(Color.BLACK);
		}

	} else {
		c = dtcr.getTableCellRendererComponent(this, "-", false, false, row, column);
		c.setForeground(Color.BLACK);
	}

	return dtcr;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:29,代码来源:PAResultsWindow.java

示例7: main

import java.awt.Component; //导入方法依赖的package包/类
public static void main(String[] args) {
    Component c = new Component() {};
    c.setBackground(Color.WHITE);
    c.setForeground(Color.BLACK);
    Graphics g = new BufferedImage(1024, 768, BufferedImage.TYPE_INT_RGB).getGraphics();
    g.setClip(0, 0, 1024, 768);
    for (Border border : BORDERS) {
        System.out.println(border.getClass());
        border.getBorderInsets(c);
        border.paintBorder(c, g, 0, 0, 1024, 768);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test6978482.java

示例8: render

import java.awt.Component; //导入方法依赖的package包/类
@Override
public void render(Graphics g, Font defaultFont, Color defaultColor,
        Color backgroundColor, int width, int height, boolean selected) {
    Component renderComponent = getPaintComponent(selected);
    renderComponent.setFont(defaultFont);
    renderComponent.setForeground(defaultColor);
    renderComponent.setBackground(backgroundColor);
    renderComponent.setBounds(0, 0, width, height);
    ((CCPaintComponent) renderComponent).paintComponent(g);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:JPACompletionItem.java

示例9: getListCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList<? extends FontDescr> list, FontDescr value, int index, boolean isSelected, boolean cellHasFocus) {
    FontDescr fd = value;
    Component c = delegate.getListCellRendererComponent(list, fd, index, isSelected, cellHasFocus);
    if (fd.isFixed()) {
        c.setForeground(Color.BLACK);
    } else {
        c.setForeground(Color.GRAY);
    }
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FontPanel.java

示例10: getTableCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Returns the component used for drawing the cell.  This method is
 * used to configure the renderer appropriately before drawing.
 *
 * @param    table        the <code>JTable</code> that is asking the
 * renderer to draw; can be <code>null</code>
 * @param    value        the value of the cell to be rendered.  It is
 * up to the specific renderer to interpret
 * and draw the value.  For example, if
 * <code>value</code>
 * is the string "true", it could be rendered as a
 * string or it could be rendered as a check
 * box that is checked.  <code>null</code> is a
 * valid value
 * @param    isSelected    true if the cell is to be rendered with the
 * selection highlighted; false otherwise
 * @param    hasFocus    if true, render cell appropriately.  For
 * example, put a special border on the cell, if
 * the cell can be edited, render in the color used
 * to indicate editing
 * @param    row     the row index of the cell being drawn.  When
 * drawing the header, the value of
 * <code>row</code> is -1
 * @param    column     the column index of the cell being drawn
 */
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
	Component renderer;
	renderer = getDrawComponent(value);
	if (table.isCellEditable(row, column)) {
		// If the cell is editable, returns a comboBox
		combo.removeAllItems();
		if (value != null) {
			combo.addItem(renderer);
			combo.setSelectedItem(value);
		}
		if (!isSelected) {
			combo.setBackground(table.getBackground());
			combo.setForeground(table.getForeground());
		} else {
			combo.setBackground(table.getSelectionBackground());
			combo.setForeground(table.getSelectionForeground());
		}
		return combo;
	} else {
		// Otherwise returns the label only.
		if (!isSelected) {
			renderer.setBackground(table.getBackground());
			renderer.setForeground(table.getForeground());
		} else {
			renderer.setBackground(table.getSelectionBackground());
			renderer.setForeground(table.getSelectionForeground());
		}
		return renderer;
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:56,代码来源:ImagedComboBoxCellEditorFactory.java

示例11: getTableCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Returns the component used for drawing the cell.  This method is
 * used to configure the renderer appropriately before drawing.
 *
 * @param    table        the <code>JTable</code> that is asking the
 * renderer to draw; can be <code>null</code>
 * @param    value        the value of the cell to be rendered.  It is
 * up to the specific renderer to interpret
 * and draw the value.  For example, if
 * <code>value</code>
 * is the string "true", it could be rendered as a
 * string or it could be rendered as a check
 * box that is checked.  <code>null</code> is a
 * valid value
 * @param    isSelected    true if the cell is to be rendered with the
 * selection highlighted; otherwise false
 * @param    hasFocus    if true, render cell appropriately.  For
 * example, put a special border on the cell, if
 * the cell can be edited, render in the color used
 * to indicate editing
 * @param    row     the row index of the cell being drawn.  When
 * drawing the header, the value of
 * <code>row</code> is -1
 * @param    column     the column index of the cell being drawn
 */
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
	Component renderer = getDrawComponent(value);
	if (table.isCellEditable(row, column)) {
		// If the cell is editable, returns a comboBox
		combo.removeAllItems();
		if (value != null) {
			combo.addItem(renderer);
			combo.setSelectedItem(value);
		}
		if (!isSelected) {
			combo.setBackground(table.getBackground());
			combo.setForeground(table.getForeground());
		} else {
			combo.setBackground(table.getSelectionBackground());
			combo.setForeground(table.getSelectionForeground());
		}
		return combo;
	} else {
		// Otherwise returns the label only.
		if (!isSelected) {
			renderer.setBackground(table.getBackground());
			renderer.setForeground(table.getForeground());
		} else {
			renderer.setBackground(table.getSelectionBackground());
			renderer.setForeground(table.getSelectionForeground());
		}
		return renderer;
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:55,代码来源:ImagedComboBoxCellEditorFactory.java

示例12: getListCellRendererComponent

import java.awt.Component; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Component getListCellRendererComponent(JList list, Object value, int index,
    boolean isSelected, boolean cellHasFocus) {
    Component result =
        super.getListCellRendererComponent(list, value, index, isSelected, false);
    Mode mode = cellHasFocus ? Mode.FOCUSED : isSelected ? Mode.SELECTED : Mode.NONE;
    result.setBackground(getColors().getBackground(mode));
    result.setForeground(getColors().getForeground(mode));
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:12,代码来源:ListPanel.java

示例13: getAnotherObject

import java.awt.Component; //导入方法依赖的package包/类
@Override
protected Component getAnotherObject() {
    Component component = new MyComponent();
    component.setForeground(Color.BLACK);
    component.setFont(new Font(null, Font.ITALIC, 6));
    return component;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:java_awt_Component.java

示例14: paintCurrentValue

import java.awt.Component; //导入方法依赖的package包/类
@Override
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) {
	ListCellRenderer renderer = this.comboBox.getRenderer();
	Component c;

	if (hasFocus && !isPopupVisible(this.comboBox)) {
		c = renderer.getListCellRendererComponent(this.listBox, this.comboBox.getSelectedItem(), -1, true, false);
	} else {
		c = renderer.getListCellRendererComponent(this.listBox, this.comboBox.getSelectedItem(), -1, false, false);
		c.setBackground(UIManager.getColor("ComboBox.background"));
	}
	c.setFont(this.comboBox.getFont());

	if (this.comboBox.isEnabled()) {
		c.setForeground(this.comboBox.getForeground());
		c.setBackground(this.comboBox.getBackground());
	} else {
		c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
		c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
	}

	boolean shouldValidate = false;
	if (c instanceof JPanel) {
		shouldValidate = true;
	}

	if (Boolean.parseBoolean(String.valueOf(comboBox.getClientProperty(RapidLookTools.PROPERTY_INPUT_BACKGROUND_DARK)))) {
		c.setBackground(Colors.COMBOBOX_BACKGROUND_DARK);
	} else {
		c.setBackground(Colors.COMBOBOX_BACKGROUND);
	}

	this.currentValuePane.paintComponent(g, c, this.comboBox, bounds.x, bounds.y, bounds.width, bounds.height,
			shouldValidate);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:36,代码来源:ComboBoxUI.java

示例15: getTableCellEditorComponent

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
	Component comp = super.getTableCellEditorComponent(table, value, isSelected, row, column);
	if (!reader.getAttributeColumn(column - 1).isActivated()) {
		comp.setForeground(Color.LIGHT_GRAY);
	} else if (reader.hasParseErrorInColumn(column - 1)) {
		comp.setForeground(BLUE);
	} else {
		comp.setForeground(Color.BLACK);
	}
	return comp;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:13,代码来源:MetaDataDeclarationEditor.java


注:本文中的java.awt.Component.setForeground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。