本文整理汇总了Java中javax.swing.JTable.setDefaultEditor方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setDefaultEditor方法的具体用法?Java JTable.setDefaultEditor怎么用?Java JTable.setDefaultEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setDefaultEditor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableFTFEditDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TableFTFEditDemo() {
super(new GridLayout(1, 0));
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Set up stricter input validation for the integer column.
table.setDefaultEditor(Integer.class, new IntegerEditor(0, 100));
// If we didn't want this editor to be used for other
// Integer columns, we'd do this:
// table.getColumnModel().getColumn(3).setCellEditor(
// new IntegerEditor(0, 100));
// Add the scroll pane to this panel.
add(scrollPane);
}
示例2: TableDialogEditDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TableDialogEditDemo() {
super(new GridLayout(1, 0));
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Set up renderer and editor for the Favorite Color column.
table.setDefaultRenderer(Color.class, new ColorRenderer(true));
table.setDefaultEditor(Color.class, new ColorEditor());
// Add the scroll pane to this panel.
add(scrollPane);
}
示例3: 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();
}
示例4: createContent
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
protected JPanel createContent() {
JPanel content = new JPanel();
GroupLayout layout = new GroupLayout(content);
content.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
// parameters panel
hhTable = new JTable();
hhTable.setAutoscrolls(true);
JScrollPane resScrollPane = new JScrollPane(hhTable);
resScrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
resScrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
hhTable.setFillsViewportHeight(true);
hhTable.setPreferredScrollableViewportSize(new Dimension(400, 100));
hhTableModel = new MyTableModel();
hhTable.setModel(hhTableModel);
hhTable.setDefaultRenderer(Class.class, new MyClassTableCellRenderer());
hhTable.setDefaultEditor(Double.class, new MyDoubleTableCellEditor());
hhTableModel.addColumn("Select");
hhTableModel.addColumn("Hidden Hop Mapping");
hhTableModel.addColumn("Factor");
JPanel hhPanel = new JPanel();
hhPanel.setBorder(BorderFactory.createTitledBorder("Hidden Hops"));
hhPanel.add(resScrollPane);
// create the content for the hh panel
for (Class<?> hh : getAllHhs()) {
try {
hh.getDeclaredField(new String("factor"));
// add a row to the factor table.
hhTableModel
.addRow(new Object[] { false, hh, new Double(0.0) });
} catch (NoSuchFieldException ex) {
}
}
// add the panels
layout.setHorizontalGroup(layout.createParallelGroup().addComponent(
hhPanel));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(
hhPanel));
return content;
}