use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class TrackTableModel method initTable.
private void initTable() {
// Use XTableColumnModel so we can control which columns are visible
XTableColumnModel tcm = new XTableColumnModel();
_table.setColumnModel(tcm);
_table.createDefaultColumnsFromModel();
// set column preferred widths
tcm.getColumn(ID_COLUMN).setPreferredWidth(40);
tcm.getColumn(NAME_COLUMN).setPreferredWidth(200);
tcm.getColumn(LENGTH_COLUMN).setPreferredWidth(Math.max(50, new JLabel(getColumnName(LENGTH_COLUMN)).getPreferredSize().width + 10));
tcm.getColumn(USED_LENGTH_COLUMN).setPreferredWidth(50);
tcm.getColumn(RESERVED_COLUMN).setPreferredWidth(Math.max(65, new JLabel(getColumnName(RESERVED_COLUMN)).getPreferredSize().width + 10));
tcm.getColumn(MOVES_COLUMN).setPreferredWidth(60);
tcm.getColumn(LOCOS_COLUMN).setPreferredWidth(60);
tcm.getColumn(CARS_COLUMN).setPreferredWidth(60);
tcm.getColumn(PICKUPS_COLUMN).setPreferredWidth(Math.max(60, new JLabel(getColumnName(PICKUPS_COLUMN)).getPreferredSize().width + 10));
tcm.getColumn(SETOUT_COLUMN).setPreferredWidth(Math.max(60, new JLabel(getColumnName(SETOUT_COLUMN)).getPreferredSize().width + 10));
tcm.getColumn(RESTRICTION_COLUMN).setPreferredWidth(90);
tcm.getColumn(LOAD_COLUMN).setPreferredWidth(50);
tcm.getColumn(SHIP_COLUMN).setPreferredWidth(50);
tcm.getColumn(ROAD_COLUMN).setPreferredWidth(50);
tcm.getColumn(DESTINATION_COLUMN).setPreferredWidth(50);
tcm.getColumn(POOL_COLUMN).setPreferredWidth(70);
tcm.getColumn(PLANPICKUP_COLUMN).setPreferredWidth(70);
tcm.getColumn(ALT_TRACK_COLUMN).setPreferredWidth(120);
tcm.getColumn(EDIT_COLUMN).setPreferredWidth(80);
tcm.getColumn(EDIT_COLUMN).setCellRenderer(new ButtonRenderer());
tcm.getColumn(EDIT_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
setColumnsVisible();
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class TrainsTableModel 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();
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(EDITCOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDITCOLUMN).setCellEditor(buttonEditor);
tcm.getColumn(ACTIONCOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(ACTIONCOLUMN).setCellEditor(buttonEditor);
tcm.getColumn(BUILDCOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(BUILDCOLUMN).setCellEditor(buttonEditor);
_table.setDefaultRenderer(Boolean.class, new EnablingCheckboxRenderer());
// set column preferred widths
for (int i = 0; i < tcm.getColumnCount(); i++) {
tcm.getColumn(i).setPreferredWidth(_tableColumnWidths[i]);
}
_frame.loadTableDetails(_table);
// turn off column
tcm.setColumnVisible(tcm.getColumnByModelIndex(IDCOLUMN), _sort == SORTBYID);
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class NodeTablePane method initComponents.
/**
* Initialize the window
*/
public void initComponents() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
nodesModel = new NodesModel();
JTable nodesTable = new JTable(nodesModel);
// install a button renderer & editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
nodesTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
nodesTable.setDefaultEditor(JButton.class, buttonEditor);
TableRowSorter<NodesModel> sorter = new TableRowSorter<>(nodesModel);
RowSorterUtil.setSortOrder(sorter, NodesModel.STATUSCOL, SortOrder.DESCENDING);
nodesTable.setRowSorter(sorter);
nodesTable.setRowSelectionAllowed(false);
nodesTable.setPreferredScrollableViewportSize(new java.awt.Dimension(580, 80));
JScrollPane scrollPane = new JScrollPane(nodesTable);
add(scrollPane);
// status info on bottom
JPanel p = new JPanel() {
@Override
public Dimension getMaximumSize() {
int height = getPreferredSize().height;
int width = super.getMaximumSize().width;
return new Dimension(width, height);
}
};
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
JButton b = new JButton(rb.getString("ButtonCheck"));
b.setToolTipText(rb.getString("TipCheck"));
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
startPoll();
}
});
p.add(b);
status = new JLabel("");
p.add(status);
p.add(Box.createHorizontalGlue());
// renumber button
b = new JButton(rb.getString("ButtonRenumber"));
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
renumber();
}
});
p.add(b);
add(p);
// start the search for nodes
startPoll();
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class StackMonDataModel method initTable.
void initTable(JTable stackTable, StackMonFrame stackFrame) {
// Install the button handlers for the Delete Buttons
TableColumnModel tcm = stackTable.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(DELCOLUMN).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(DELCOLUMN).setCellEditor(buttonEditor);
_stackFrame = stackFrame;
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class SlotMonDataModel method setColumnToHoldButton.
void setColumnToHoldButton(JTable slotTable, int column) {
TableColumnModel tcm = slotTable.getColumnModel();
// install the button renderers & editors in this column
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(column).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
tcm.getColumn(column).setCellEditor(buttonEditor);
// ensure the table rows, columns have enough room for buttons
slotTable.setRowHeight(new JButton(" " + getValueAt(1, column)).getPreferredSize().height);
slotTable.getColumnModel().getColumn(column).setPreferredWidth(new JButton(" " + getValueAt(1, column)).getPreferredSize().width);
}
Aggregations