本文整理汇总了Java中javax.swing.JTable.getForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.getForeground方法的具体用法?Java JTable.getForeground怎么用?Java JTable.getForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.getForeground方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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)
);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}