use of javax.swing.JTable in project JMRI by JMRI.
the class EcosLocoTableAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// create the JTable model, with changes for specific NamedBean
createModel();
TableRowSorter<BeanTableDataModel> sorter = new TableRowSorter<>(m);
JTable dataTable = m.makeJTable(getClassName(), m, sorter);
// create the frame
f = new jmri.jmrit.beantable.BeanTableFrame(m, helpTarget(), dataTable) {
};
setMenuBar(f);
setTitle();
addToFrame(f);
f.pack();
f.setVisible(true);
}
use of javax.swing.JTable in project processdash by dtuma.
the class SizeMetricsTableModel method createJTable.
public JTable createJTable() {
JTable table = new ItemListJTable(this);
// adjust column widths
table.getColumnModel().getColumn(0).setPreferredWidth(100);
table.getColumnModel().getColumn(1).setPreferredWidth(200);
table.getColumnModel().getColumn(2).setPreferredWidth(100);
table.setRowHeight(table.getRowHeight() + 4);
// draw read-only phases with a different appearance
table.setDefaultRenderer(String.class, new ItemTableCellRenderer());
// install a combo box as the editor for the "phase type" column
TableColumn unitsColumn = table.getColumnModel().getColumn(UNITS_COL);
JComboBox unitsEditor = new JComboBox(UNITS_TYPES);
unitsEditor.setRenderer(new UnitsCellRenderer());
unitsEditor.setFont(unitsEditor.getFont().deriveFont(Font.PLAIN));
unitsColumn.setCellEditor(new DefaultCellEditor(unitsEditor));
return table;
}
use of javax.swing.JTable in project processdash by dtuma.
the class ManuallyEnteredPreferencesList method createList.
@Override
protected void createList(String id, String currentValue) {
Object[][] data = getCurrentData(currentValue);
String settingColumnName = map.getResource(id + ".Setting_Column");
String valueColumnName = map.getResource(id + ".Value_Column");
Object[] columns = { settingColumnName, valueColumnName };
tableModel = new DefaultTableModel(data, columns) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
settingTable = new JTable(tableModel);
settingTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
settingTable.getSelectionModel().addListSelectionListener(this);
JScrollPane listScroller = new JScrollPane(settingTable);
listScroller.setPreferredSize(new Dimension(LIST_WIDTH, LIST_HEIGHT));
this.add(listScroller, BorderLayout.CENTER);
}
use of javax.swing.JTable in project processdash by dtuma.
the class UserEditor method makeTable.
private Component makeTable() {
table = new JTable(model);
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
rowSorter = new TableRowSorter(model);
rowSorter.setSortable(UserTableModel.ROLES_COL, false);
table.setRowSorter(rowSorter);
table.getColumnModel().getColumn(UserTableModel.USERNAME_COL).setCellEditor(new UsernameCellEditor());
table.getColumnModel().getColumn(UserTableModel.ROLES_COL).setCellEditor(new RolesCellEditor());
table.getColumnModel().getColumn(UserTableModel.ROLES_COL).setHeaderRenderer(new RolesHeaderRenderer());
table.getTableHeader().addMouseListener(new RolesColumnClickHandler());
int preferredWidth = TableUtils.configureTable(table, UserTableModel.COLUMN_WIDTHS, UserTableModel.COLUMN_TOOLTIPS);
int preferredHeight = 15 * table.getRowHeight();
table.setPreferredScrollableViewportSize(new Dimension(preferredWidth, preferredHeight));
// active, not us; so don't display the "Active" column in the table.
if (isLegacyPdesMode()) {
table.getColumnModel().removeColumn(table.getColumnModel().getColumn(UserTableModel.ACTIVE_COL));
}
return new JScrollPane(table);
}
use of javax.swing.JTable in project processdash by dtuma.
the class EVMetricsWidget method getWidgetComponent.
public Component getWidgetComponent(Map environment, Map parameters) {
EVSchedule schedule = (EVSchedule) environment.get(EVSnippetEnvironment.SCHEDULE_KEY);
EVMetrics m = schedule.getMetrics();
JTable table = new JTable(m);
table.removeColumn(table.getColumnModel().getColumn(3));
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setPreferredSize(new Dimension(100, 100));
DescriptionPane descr = new DescriptionPane(m, table.getSelectionModel());
Box result = Box.createVerticalBox();
result.add(scrollPane);
result.add(Box.createVerticalStrut(2));
result.add(descr);
return result;
}
Aggregations