當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。