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


Java DefaultTableCellRenderer.setBackground方法代码示例

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


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

示例1: checkTableGridLines

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
private static void checkTableGridLines() {

        TableModel dataModel = new AbstractTableModel() {
            public int getColumnCount() {
                return 10;
            }

            public int getRowCount() {
                return 10;
            }

            public Object getValueAt(int row, int col) {
                return " ";
            }
        };

        DefaultTableCellRenderer r = new DefaultTableCellRenderer();
        r.setOpaque(true);
        r.setBackground(CELL_RENDERER_BACKGROUND_COLOR);

        JTable table = new JTable(dataModel);
        table.setSize(WIDTH, HEIGHT);
        table.setDefaultRenderer(Object.class, r);
        table.setGridColor(GRID_COLOR);
        table.setShowGrid(true);
        table.setShowHorizontalLines(true);
        table.setShowVerticalLines(true);
        table.setBackground(TABLE_BACKGROUND_COLOR);

        checkTableGridLines(table);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:DrawGridLinesTest.java

示例2: setCellBackground

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public void setCellBackground(Color color, int columnindex) {
	if (columnindex < 0 || columnindex >= getColumnCount())
		return;

	DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
	TableColumn column = jtable.getTableHeader().getColumnModel()
			.getColumn(columnindex);
	renderer.setBackground(color);
	column.setCellRenderer(renderer);

}
 
开发者ID:Jasig,项目名称:ImageQuiz,代码行数:12,代码来源:CheckBoxTable.java

示例3: 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

示例4: createTemplatePanel

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public JPanel createTemplatePanel()
{
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    panel.setPreferredSize(new Dimension(Editor.TEMPLATE_BLOCK_WIDTH,Editor.TEMPLATE_BLOCK_HEIGHT));
    panel.setLayout(new BorderLayout());
    panel.setBackground(Color.WHITE);

    templateTable  = new JTable(new TemplateModel(new ArrayList<Template>()));
    templateTable.setGridColor(Color.WHITE);
    templateTable.setDefaultRenderer(templateTable.getColumnClass(0), new ColorCellRenderer());
    DefaultTableCellRenderer tableCellRenderer = (DefaultTableCellRenderer)templateTable.getDefaultRenderer(String.class);
    tableCellRenderer.setBackground(Color.WHITE);
    templateTable.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e){
            if (e.getClickCount() == 2){
                int row = ((JTable)e.getSource()).getSelectedRow();
                performTemplate(row);
            }
        }
    });

    panel.add(templateTable,BorderLayout.NORTH);
    
    JPanel isButtonPanel = new JPanel();
    isButtonPanel.setLayout(new BoxLayout(isButtonPanel,BoxLayout.X_AXIS));
    isButtonPanel.setBackground(Color.WHITE);
    isButtonPanel.setPreferredSize(new Dimension(Editor.IS_BLOCK_WIDTH,Editor.BUTTON_PANEL_HEIGHT));

    JButton applyButton = new JButton(APPLYALL);
    applyButton.addActionListener(new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent arg0) {
            performAllTemplates();
        }
    });
    isButtonPanel.add(applyButton);
    
    panel.add(isButtonPanel,BorderLayout.SOUTH);

    return panel;
}
 
开发者ID:ARIA-VALUSPA,项目名称:Flipper,代码行数:43,代码来源:RunnerPanel.java


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