本文整理汇总了Java中javax.swing.JTable.getDefaultRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.getDefaultRenderer方法的具体用法?Java JTable.getDefaultRenderer怎么用?Java JTable.getDefaultRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.getDefaultRenderer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableCellRendererComponent
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
Component component = super.getTableCellRendererComponent(table,
value, isSelected, hasFocus, row, column);
if (value != null) {
if (component instanceof JLabel)
((JLabel) component)
.setText(DateAttributePlugin.DATE_INSTANCE
.format(value));
else {
TableCellRenderer renderer = table
.getDefaultRenderer(Date.class);
return renderer.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
}
}
return component;
}
示例2: getTableCellRendererComponent
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
Component component = super.getTableCellRendererComponent(table,
value, isSelected, hasFocus, row, column);
if (value != null) {
if (component instanceof JLabel)
((JLabel) component).setText(DATE_INSTANCE.format(value));
else {
TableCellRenderer renderer = table
.getDefaultRenderer(Date.class);
return renderer.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
}
}
return component;
}
示例3: apply
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Applies DisablingCellRenderer to all cell renderers in the table.
* @param t the table
* @param disabled if the table content should be disabled
*/
public static void apply(JTable t, Color background) {
int nc = t.getColumnModel().getColumnCount();
for (int i = 0; i < nc; i++) {
TableCellRenderer columnRenderer = t.getColumnModel().getColumn(i).getCellRenderer();
if (columnRenderer == null) columnRenderer = t.getDefaultRenderer(t.getColumnClass(i));
t.getColumnModel().getColumn(i).setCellRenderer(
new DisablingCellRenderer(columnRenderer, t, background));
}
}
示例4: getTableCellRendererComponent
import javax.swing.JTable; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,
int row, int column) {
if (impl == null) impl = table.getDefaultRenderer(table.getColumnClass(column));
value = formatValue(table, value, isSelected, hasFocus, row, column);
Component c = impl.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);
updateRenderer(c, table, value, isSelected, hasFocus, row, column);
return c;
}
示例5: getTableCellRendererComponent
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
TableCellRenderer def = table.getDefaultRenderer(table.getColumnClass(column));
if (!table.isEnabled()) {
isSelected = hasFocus = false;
}
JComponent c = (JComponent)def.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setEnabled(table.isEnabled());
return c;
}
示例6: AttrTable
import javax.swing.JTable; //导入方法依赖的package包/类
public AttrTable(Window parent) {
super(new BorderLayout());
this.parent = parent;
titleEnabled = true;
title = new TitleLabel();
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setVerticalAlignment(SwingConstants.CENTER);
tableModel = new TableModelAdapter(parent, NULL_ATTR_MODEL);
table = new JTable(tableModel);
table.setDefaultEditor(Object.class, editor);
table.setTableHeader(null);
table.setRowHeight(20);
Font baseFont = title.getFont();
int titleSize = Math.round(baseFont.getSize() * 1.2f);
Font titleFont = baseFont.deriveFont((float) titleSize).deriveFont(Font.BOLD);
title.setFont(titleFont);
Color bgColor = new Color(240, 240, 240);
setBackground(bgColor);
table.setBackground(bgColor);
Object renderer = table.getDefaultRenderer(String.class);
if (renderer instanceof JComponent) {
((JComponent) renderer).setBackground(Color.WHITE);
}
JScrollPane tableScroll = new JScrollPane(table);
this.add(title, BorderLayout.PAGE_START);
this.add(tableScroll, BorderLayout.CENTER);
LocaleManager.addLocaleListener(this);
localeChanged();
}