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


Java DefaultTableCellRenderer.setForeground方法代码示例

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


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

示例1: getCellRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
/**
 * This method sets read write rows to be blue, and other rows to be their
 * default rendered colour.
 */
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
    DefaultTableCellRenderer tcr =
        (DefaultTableCellRenderer) super.getCellRenderer(row,column);
    tcr.setToolTipText(getToolTip(row,column));
    if (defaultColor == null) {
        defaultColor = tcr.getForeground();
        editableColor = Color.blue;
        errorColor = Color.red;
        // this sometimes happens for some reason
        if (defaultColor == null) {
            return tcr;
        }
    }
    if (column != VALUE_COLUMN) {
        tcr.setForeground(defaultColor);
        return tcr;
    }
    if (isCellError(row,column)) {
        tcr.setForeground(errorColor);
    } else if (isCellEditable(row, column)) {
        tcr.setForeground(editableColor);
    } else {
        tcr.setForeground(defaultColor);
    }
    return tcr;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:XTable.java

示例2: initialiseRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
private void initialiseRenderer(int modelColumnIndex, Color color) {
 if (modelColumnIndex < 0) {
     return;
 }

 int viewColumnIndex = table.convertColumnIndexToView(modelColumnIndex);
 DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
 renderer.setHorizontalAlignment(JLabel.CENTER);
 if (color != null) {
     renderer.setForeground(color);
 }
 table.getColumnModel().getColumn(viewColumnIndex).setCellRenderer(renderer);;
}
 
开发者ID:kddart,项目名称:kdxplore,代码行数:14,代码来源:AddTraitsDialog.java

示例3: setCellForeground

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public void setCellForeground(Color color, int columnindex) {

		if (columnindex < 0 || columnindex >= getColumnCount())
			return;

		DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		TableColumn column = jtable.getTableHeader().getColumnModel()
				.getColumn(columnindex);
		renderer.setForeground(color);
		column.setCellRenderer(renderer);
	}
 
开发者ID:Jasig,项目名称:ImageQuiz,代码行数:12,代码来源:CheckBoxTable.java

示例4: testTableUnSelectedDoNothingHighlighter

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
/**
 * Issue #258-swingx: DefaultTableCellRenderer has memory. 
 * How to formulate as test?
 * this is testing the hack (reset the memory in ResetDTCR to null), not
 * any highlighter!
 */
public void testTableUnSelectedDoNothingHighlighter() {
    JXTable table = new JXTable(10, 2);
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setForeground(foreground);
    table.setHighlighters(new ColorHighlighter());
    Component comp = table.prepareRenderer(renderer, 0, 0);
    assertEquals("do nothing highlighter must not change foreground", foreground, comp.getForeground());
    fail("testing the hack around DefaultTableCellRenderer memory - not the memory itself");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:16,代码来源:HighlighterIssues.java

示例5: interactiveTableCustomCoreRendererColor

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
/**
 * Issue #258-swingx: Background LegacyHighlighter must not change custom
 * foreground.
 * <p>
 * 
 * Visualizing effect of hack: table-internally, a ResetDTCRColorHighlighter
 * tries to neutralize DefaultTableCellRenderer's color memory.
 * 
 * <ul>
 * <li> a DTCR with custom foreground and custom background
 * <li> the renderer is shared between a table with background highlighter
 * (alternateRowHighlighter) and a table without highlighter
 * <li> the custom foreground must show in both
 * <li> the custom background must show in the table without highlighter
 * <li> the custom background must not show in the table with highlighter
 * (AlternateRowHighlighter overwrite both striped and unstriped back)
 * </ul>
 * 
 */
public void interactiveTableCustomCoreRendererColor() {
    TableModel model = new AncientSwingTeam();
    JXTable table = new JXTable(model);
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setForeground(foreground);
    renderer.setBackground(background);
    table.addHighlighter(
            HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));

    table.setDefaultRenderer(Object.class, renderer);
    JXTable nohighlight = new JXTable(model);
    nohighlight.setDefaultRenderer(Object.class, renderer);
    showWithScrollingInFrame(table, nohighlight,
            "core: custom colored renderer with bg highlighter <--> shared without highl");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:35,代码来源:HighlighterIssues.java


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