use of javax.swing.table.TableCellEditor in project JMRI by JMRI.
the class LocationsTableModel method initTable.
void initTable(LocationsTableFrame frame, JTable table) {
// Install the button handlers
TableColumnModel tcm = table.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(ACTIONCOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(ACTIONCOLUMN).setCellEditor(buttonEditor);
tcm.getColumn(EDITCOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDITCOLUMN).setCellEditor(buttonEditor);
// set column preferred widths
table.getColumnModel().getColumn(IDCOLUMN).setPreferredWidth(40);
table.getColumnModel().getColumn(NAMECOLUMN).setPreferredWidth(200);
table.getColumnModel().getColumn(TRACKCOLUMN).setPreferredWidth(Math.max(60, new JLabel(Bundle.getMessage("Class/Interchange") + Bundle.getMessage("Spurs") + Bundle.getMessage("Yards")).getPreferredSize().width + 20));
table.getColumnModel().getColumn(LENGTHCOLUMN).setPreferredWidth(Math.max(60, new JLabel(getColumnName(LENGTHCOLUMN)).getPreferredSize().width + 10));
table.getColumnModel().getColumn(USEDLENGTHCOLUMN).setPreferredWidth(60);
table.getColumnModel().getColumn(ROLLINGSTOCK).setPreferredWidth(Math.max(80, new JLabel(getColumnName(ROLLINGSTOCK)).getPreferredSize().width + 10));
table.getColumnModel().getColumn(PICKUPS).setPreferredWidth(Math.max(60, new JLabel(getColumnName(PICKUPS)).getPreferredSize().width + 10));
table.getColumnModel().getColumn(DROPS).setPreferredWidth(Math.max(60, new JLabel(getColumnName(DROPS)).getPreferredSize().width + 10));
table.getColumnModel().getColumn(ACTIONCOLUMN).setPreferredWidth(Math.max(80, new JLabel(Bundle.getMessage("Yardmaster")).getPreferredSize().width + 40));
table.getColumnModel().getColumn(EDITCOLUMN).setPreferredWidth(80);
frame.loadTableDetails(table);
}
use of javax.swing.table.TableCellEditor in project JMRI by JMRI.
the class CarsTableModel method initTable.
void initTable() {
// Use XTableColumnModel so we can control which columns are visible
XTableColumnModel tcm = new XTableColumnModel();
_table.setColumnModel(tcm);
_table.createDefaultColumnsFromModel();
// Install the button handlers
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(SET_COLUMN).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(SET_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(EDIT_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDIT_COLUMN).setCellEditor(buttonEditor);
// set column preferred widths
for (int i = 0; i < tcm.getColumnCount(); i++) {
tcm.getColumn(i).setPreferredWidth(tableColumnWidths[i]);
}
_frame.loadTableDetails(_table);
// turn off columns
tcm.setColumnVisible(tcm.getColumnByModelIndex(SELECT_COLUMN), isSelectVisible);
tcm.setColumnVisible(tcm.getColumnByModelIndex(COLOR_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(FINAL_DESTINATION_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RWE_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RWE_LOAD_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(BUILT_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(OWNER_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(VALUE_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_WHEN_LAST_SEEN_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_WHERE_LAST_SEEN_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(WAIT_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(PICKUP_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(LAST_COLUMN), false);
}
use of javax.swing.table.TableCellEditor in project JMRI by JMRI.
the class RouteEditTableModel method initTable.
private void initTable(JTable table) {
// Install the button handlers
TableColumnModel tcm = table.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(COMMENT_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(COMMENT_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(UP_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(UP_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(DOWN_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(DOWN_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(DELETE_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(DELETE_COLUMN).setCellEditor(buttonEditor);
table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
// set column preferred widths
table.getColumnModel().getColumn(ID_COLUMN).setPreferredWidth(40);
table.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(150);
table.getColumnModel().getColumn(TRAIN_DIRECTION_COLUMN).setPreferredWidth(95);
table.getColumnModel().getColumn(MAXMOVES_COLUMN).setPreferredWidth(50);
table.getColumnModel().getColumn(RANDOM_CONTROL_COLUMN).setPreferredWidth(65);
table.getColumnModel().getColumn(PICKUP_COLUMN).setPreferredWidth(65);
table.getColumnModel().getColumn(DROP_COLUMN).setPreferredWidth(65);
table.getColumnModel().getColumn(WAIT_COLUMN).setPreferredWidth(65);
table.getColumnModel().getColumn(MAXLENGTH_COLUMN).setPreferredWidth(75);
table.getColumnModel().getColumn(GRADE).setPreferredWidth(50);
table.getColumnModel().getColumn(TRAINICONX).setPreferredWidth(35);
table.getColumnModel().getColumn(TRAINICONY).setPreferredWidth(35);
table.getColumnModel().getColumn(COMMENT_COLUMN).setPreferredWidth(70);
table.getColumnModel().getColumn(UP_COLUMN).setPreferredWidth(60);
table.getColumnModel().getColumn(DOWN_COLUMN).setPreferredWidth(70);
table.getColumnModel().getColumn(DELETE_COLUMN).setPreferredWidth(70);
_frame.loadTableDetails(table);
// does not use a table sorter
table.setRowSorter(null);
updateList();
}
use of javax.swing.table.TableCellEditor in project JMRI by JMRI.
the class RoutesTableModel method initTable.
void initTable(RoutesTableFrame frame, JTable table) {
// Install the button handlers
TableColumnModel tcm = table.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(EDIT_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDIT_COLUMN).setCellEditor(buttonEditor);
// set column preferred widths
table.getColumnModel().getColumn(ID_COLUMN).setPreferredWidth(30);
table.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(220);
table.getColumnModel().getColumn(COMMENT_COLUMN).setPreferredWidth(380);
table.getColumnModel().getColumn(STATUS_COLUMN).setPreferredWidth(70);
table.getColumnModel().getColumn(MIN_LENGTH_COLUMN).setPreferredWidth(75);
table.getColumnModel().getColumn(MAX_LENGTH_COLUMN).setPreferredWidth(75);
table.getColumnModel().getColumn(EDIT_COLUMN).setPreferredWidth(80);
frame.loadTableDetails(table);
}
use of javax.swing.table.TableCellEditor in project JMRI by JMRI.
the class EditorTableDataModel method setColumnToHoldButton.
/**
* Service method to setup a column so that it will hold a button for it's
* values
*
* @param sample Typical button, used for size
*/
void setColumnToHoldButton(JTable table, int column, JButton sample) {
//TableColumnModel tcm = table.getColumnModel();
// install a button renderer & editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
table.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
table.setDefaultEditor(JButton.class, buttonEditor);
// ensure the table rows, columns have enough room for buttons
table.setRowHeight(sample.getPreferredSize().height);
table.getColumnModel().getColumn(column).setPreferredWidth(sample.getPreferredSize().width + 30);
}
Aggregations