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


Java DefaultTableCellRenderer.setOpaque方法代码示例

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


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

示例1: prepareRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public Component prepareRenderer(
        TableCellRenderer renderer,
        int row,
        int column) {
    
    SwitcherTableItem item
            = (SwitcherTableItem) getSwitcherTableModel().getValueAt(row, column);
    
    boolean selected = row == getSelectedRow() &&
            column == getSelectedColumn() && item != null;
    
    DefaultTableCellRenderer ren = (DefaultTableCellRenderer)
    renderer.getTableCellRendererComponent(this, item,
            selected, selected, row, column);
    
    if (item == null) {
        // it's a filler space, we're done
        ren.setOpaque(false);
        ren.setIcon(null);
        return ren;
    }
    
    Icon icon = item.getIcon();
    if (icon == null ) {
        icon = nullIcon;
    }
    ren.setText(selected || item.isActive() ? stripHtml( item.getHtmlName() ) : item.getHtmlName());
    ren.setIcon(icon);
    ren.setBorder(rendererBorder);
    ren.setIconTextGap(42 - icon.getIconWidth());
    
    if (item.isActive()) {
        // don't use deriveFont() - see #49973 for details
        ren.setFont(new Font(getFont().getName(), Font.BOLD, getFont().getSize()));
    }
    
    ren.setOpaque(true);
    
    return ren;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:SwitcherTable.java

示例2: installUI

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    JTableHeader j = (JTableHeader) c;
    j.setOpaque(false);

    DefaultTableCellRenderer dtcr = (DefaultTableCellRenderer) j.getDefaultRenderer();
    dtcr.setOpaque(false);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:11,代码来源:FreeColTableHeaderUI.java

示例3: getTableCellRendererComponent

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    DefaultTableCellRenderer cellRenderer = (DefaultTableCellRenderer) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    if (column == IssuesTableModel.IssueColumn.SEVERITY.ordinal()) {
        cellRenderer.setIcon(IconUtils.load(value.toString()));
        cellRenderer.setOpaque(true);
    } else {
        cellRenderer.setIcon(null);
    }

    return cellRenderer;
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:13,代码来源:IssuesTableCellRenderer.java

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

示例5: prepareRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public Component prepareRenderer(
        TableCellRenderer renderer,
        int row,
        int column) {
    
    SwitcherTableItem item
            = (SwitcherTableItem) getSwitcherTableModel().getValueAt(row, column);
    
    boolean selected = row == getSelectedRow() &&
            column == getSelectedColumn() && item != null;
    
    DefaultTableCellRenderer ren = (DefaultTableCellRenderer)
    renderer.getTableCellRendererComponent(this, item,
            selected, selected, row, column);
    
    if (item == null) {
        // it's a filler space, we're done
        ren.setOpaque(false);
        ren.setIcon(null);
        return ren;
    }
    
    Icon icon = item.getIcon();
    if (icon == null ) {
        icon = nullIcon;
    }
    ren.setText(selected || item.isActive() ? stripHtml( item.getHtmlName() ) : item.getHtmlName());
    ren.setIcon(icon);
    ren.setBorder(rendererBorder);
    ren.setIconTextGap(26 - icon.getIconWidth());
    
    if (item.isActive()) {
        if( Utilities.isWindows() ) {
            ren.setFont(getFont().deriveFont(Font.BOLD, getFont().getSize()));
        } else {
            // don't use deriveFont() - see #49973 for details
            ren.setFont(new Font(getFont().getName(), Font.BOLD, getFont().getSize()));
        }
    }
    
    ren.setOpaque(true);
    
    return ren;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:SwitcherTable.java


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