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


Java JTable.getSelectionBackground方法代码示例

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


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

示例1: getTableCellRendererComponent

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

    if (hasFocus) {
        setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
    } else {
        setBorder(noFocusBorder);
    }

    return this;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:22,代码来源:ElistTable.java

示例2: getDefaultCellStyle

import javax.swing.JTable; //导入方法依赖的package包/类
public static TableCellStyle getDefaultCellStyle(JTable table, IssueTable issueTable, IssueProperty p, boolean isSelected, int row) {
    // set default values
    return new TableCellStyle(
        null,                                                                       // format
        isSelected ? table.getSelectionBackground() : getUnselectedBackground(row), // background
        isSelected ? Color.WHITE : table.getForeground(),                           // foreground
        null,                                                                       // tooltip
        getHightlightPattern(issueTable, p)
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:QueryTableCellRenderer.java

示例3: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
	int row, int column)
{
	setEnabled(table.getModel().isCellEditable(row, column));

	if( isSelected )
	{
		setForeground(table.getSelectionForeground());
		super.setBackground(table.getSelectionBackground());
	}
	else
	{
		setForeground(table.getForeground());
		setBackground(table.getBackground());
	}
	setSelected((value != null && ((Boolean) value).booleanValue()));

	if( hasFocus )
	{
		setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); //$NON-NLS-1$
	}
	else
	{
		setBorder(noFocusBorder);
	}

	return this;
}
 
开发者ID:equella,项目名称:Equella,代码行数:30,代码来源:OverrideRenderer.java

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

示例5: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
/**
  * @see javax.swing.table.TableCellRenderer.getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)
  */
 @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
    int row, int column) {
   Icon icon = null;
   String tooltipText = null;
   String labelText = "";
   
   JLabel tableCellRendererComponent = (JLabel) super.getTableCellRendererComponent(
       table, value, isSelected, hasFocus, row, column);
   
   if (value instanceof GitChangeType) {
     RenderingInfo renderingInfo = getRenderingInfo((GitChangeType) value);
     if (renderingInfo != null) {
       icon = renderingInfo.getIcon();
       tooltipText = renderingInfo.getTooltip();
     }
   } else if (value instanceof String) {
     tooltipText = (String) value;
     String fileName = tooltipText.substring(tooltipText.lastIndexOf('/') + 1);
     if (!fileName.equals(tooltipText)) {
       tooltipText = tooltipText.replace("/" + fileName, "");
       tooltipText = fileName + " - " + tooltipText;
     }
     labelText = (String) value;
   }
   
   tableCellRendererComponent.setIcon(icon);
   tableCellRendererComponent.setToolTipText(tooltipText);
   tableCellRendererComponent.setText(labelText);
   
   // Active/inactive table selection
   if (table.isRowSelected(row)) {
     if (table.hasFocus()) {
       tableCellRendererComponent.setBackground(table.getSelectionBackground());
     } else if (!isContextMenuShowing) {
       Color defaultColor = table.getSelectionBackground();
       tableCellRendererComponent.setBackground(getInactiveSelectionColor(defaultColor));
     }
   } else {
     tableCellRendererComponent.setBackground(table.getBackground());
   }

   return tableCellRendererComponent;
 }
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:48,代码来源:ChangesPanel.java

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

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