本文整理汇总了Java中javax.swing.table.DefaultTableCellRenderer.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTableCellRenderer.setIcon方法的具体用法?Java DefaultTableCellRenderer.setIcon怎么用?Java DefaultTableCellRenderer.setIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.DefaultTableCellRenderer
的用法示例。
在下文中一共展示了DefaultTableCellRenderer.setIcon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableCellRendererComponent
import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setBackground(Constants.DS_BACK);
DefaultTableCellRenderer r = ((DefaultTableCellRenderer) c);
r.setText("<html><b>" + r.getText() + "</b></html>");
try {
List<? extends SortKey> sortKeys = table.getRowSorter().getSortKeys();
SortKey key = sortKeys.get(0);
if (column == key.getColumn()) {
r.setIcon(key.getSortOrder() == SortOrder.ASCENDING ? ascIcon : descIcon);
} else {
r.setIcon(null);
}
} catch (Exception e) {
r.setIcon(null);
}
return r;
}
示例2: 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;
}
示例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;
}
示例4: getRenderer
import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
@Nullable
@Override
public TableCellRenderer getRenderer(UpdaterTreeNode node) {
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer() {
@Override
public void setText(String text) {
}
};
renderer.setIcon(valueOf(node));
return renderer;
}
示例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;
}