本文整理匯總了Java中javax.swing.table.DefaultTableCellRenderer.setFont方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTableCellRenderer.setFont方法的具體用法?Java DefaultTableCellRenderer.setFont怎麽用?Java DefaultTableCellRenderer.setFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.table.DefaultTableCellRenderer
的用法示例。
在下文中一共展示了DefaultTableCellRenderer.setFont方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: setCellFont
import javax.swing.table.DefaultTableCellRenderer; //導入方法依賴的package包/類
public void setCellFont(Font font, int columnindex) {
if (columnindex < 0 || columnindex >= getColumnCount())
return;
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
TableColumn column = jtable.getTableHeader().getColumnModel()
.getColumn(columnindex);
renderer.setFont(font);
column.setCellRenderer(renderer);
}
示例3: 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;
}