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


Java JTable.getSelectionForeground方法代码示例

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


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

示例1: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(final JTable table,
                                               final Object value, final boolean isSelected,
                                               final boolean hasFocus, final int row, final int column) {
    if (isSelected) {
        super.setForeground(table.getSelectionForeground());
        super.setBackground(table.getSelectionBackground());
    } else {
        super.setForeground(table.getForeground());
        super.setBackground(table.getBackground());
    }

    setFont(table.getFont());

    if (hasFocus) {
        Border border = null;
        if (isSelected) {
            border = UIManager
                    .getBorder("Table.focusSelectedCellHighlightBorder");
        }
        if (border == null) {
            border = UIManager
                    .getBorder("Table.focusCellHighlightBorder");
        }
        setBorder(border);
    } else {
        setBorder(noFocusBorder);
    }
    return this;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:30,代码来源:SectorRowsEditor.java

示例2: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column ) {
    renderer.clear();
    Rectangle rect = table.getCellRect( row, column, true );
    renderer.setSize( rect.width, rect.height );
    if( value instanceof TabData ) {
        TabData tab = ( TabData ) value;
        String text = tab.getText();
        Icon icon = tab.getIcon();
        Color colBackground = isSelected ? table.getSelectionBackground() : table.getBackground();
        Color colForeground = isSelected ? table.getSelectionForeground() : table.getForeground();

        for( TabDecorator td : decorators ) {
            Color c = td.getBackground( tab, isSelected );
            if( null != c )
                colBackground = c;
            c = td.getForeground( tab, isSelected );
            if( null != c )
                colForeground = c;

            String s = td.getText( tab );
            if( null != s )
                text = s;

            Icon i = td.getIcon( tab );
            if( null != i ) {
                icon = i;
            }
        }
        renderer.label.setText( text );
        renderer.label.setIcon( icon );
        renderer.label.setFont( table.getFont() );
        renderer.setBackground( colBackground );
        renderer.label.setForeground( colForeground );
        renderer.tabData = tab;
        renderer.isSelected = isSelected;

        if( table instanceof TabTable ) {
            TabTable tabTable = ( TabTable ) table;
            if( isClosable(tab) ) {
                boolean inCloseButton = tabTable.isCloseButtonHighlighted( row, column );
                renderer.closeButton.setVisible( true );
                renderer.closeButton.getModel().setRollover( inCloseButton );
                renderer.closeButton.getModel().setArmed( inCloseButton );
            } else {
                renderer.closeButton.setVisible( false );
            }
        }
    }
    return renderer;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:TabDataRenderer.java

示例3: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
    if (value == null) {
        return new DefaultTableCellRenderer().getTableCellRendererComponent(table, value,
                isSelected, hasFocus, row, column);
    }

    if (isSelected) {
        super.setForeground(table.getSelectionForeground());
        super.setBackground(table.getSelectionBackground());
    } else {
        super.setForeground(table.getForeground());
        super.setBackground(table.getBackground());
    }

    setFont(table.getFont());

    if (hasFocus) {
        Border border = null;
        if (isSelected) {
            border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder"); // NOI18N
        }
        if (border == null) {
            border = UIManager.getBorder("Table.focusCellHighlightBorder"); // NOI18N
        }
        setBorder(border);
    } else {
        setBorder(new EmptyBorder(1, 1, 1, 1));
    }


    FileCoverageSummary summary = (FileCoverageSummary) table.getValueAt(row, -1);
    FileObject file = summary.getFile();

    setText(summary.getDisplayName());
    if (file != null && file.isValid()) {
        try {
            DataObject dobj = DataObject.find(file);
            Node node = dobj.getNodeDelegate();
            Image icon = node.getIcon(BeanInfo.ICON_COLOR_32x32);
            setIcon(new ImageIcon(icon));
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        }
    } else {
        setIcon(null);
    }


    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:CoverageReportTopComponent.java


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