本文整理匯總了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();
}