use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class LogixTableAction method makeEditConditionalWindow.
// ********************* Edit Conditional Window and Methods *******************
/**
* Create and/or initialize the Edit Conditional window.
* <p>
* Note: you can get here via the New Conditional button (newConditionalPressed)
* or via an Edit button in the Conditional table of the Edit Logix window.
*/
void makeEditConditionalWindow() {
// deactivate this Logix
_curLogix.deActivateLogix();
conditionalUserName.setText(_curConditional.getUserName());
if (editConditionalFrame == null) {
editConditionalFrame = new JmriJFrame(rbx.getString("TitleEditConditional"), false, false);
editConditionalFrame.addHelpMenu("package.jmri.jmrit.beantable.ConditionalAddEdit", true);
Container contentPane = editConditionalFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
panel1.add(new JLabel(Bundle.getMessage("ColumnSystemName") + ":"));
panel1.add(new JLabel(_curConditional.getSystemName()));
contentPane.add(panel1);
JPanel panel2 = new JPanel();
panel2.setLayout(new FlowLayout());
panel2.add(new JLabel(Bundle.getMessage("ColumnUserName") + ":"));
panel2.add(conditionalUserName);
conditionalUserName.setToolTipText(rbx.getString("ConditionalUserNameHint"));
contentPane.add(panel2);
// add Logical Expression Section
JPanel logicPanel = new JPanel();
logicPanel.setLayout(new BoxLayout(logicPanel, BoxLayout.Y_AXIS));
// add Antecedent Expression Panel -ONLY appears for MIXED operator statements
_antecedent = _curConditional.getAntecedentExpression();
_logicType = _curConditional.getLogicType();
_antecedentField = new JTextField(65);
_antecedentField.setFont(new Font("SansSerif", Font.BOLD, 14));
_antecedentField.setText(_antecedent);
_antecedentPanel = makeEditPanel(_antecedentField, "LabelAntecedent", "LabelAntecedentHint");
JButton helpButton = new JButton(Bundle.getMessage("MenuHelp"));
_antecedentPanel.add(helpButton);
helpButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
helpPressed(e);
}
});
_antecedentPanel.add(helpButton);
_antecedentPanel.setVisible(_logicType == Conditional.MIXED);
logicPanel.add(_antecedentPanel);
// add state variable table title
JPanel varTitle = new JPanel();
varTitle.setLayout(new FlowLayout());
varTitle.add(new JLabel(rbx.getString("StateVariableTableTitle")));
logicPanel.add(varTitle);
// set up state variables table
// initialize and populate Combo boxes for table of state variables
_notOperatorBox = new JComboBox<String>();
_notOperatorBox.addItem(" ");
_notOperatorBox.addItem(Bundle.getMessage("LogicNOT"));
_andOperatorBox = new JComboBox<String>();
_andOperatorBox.addItem(Bundle.getMessage("LogicAND"));
_andOperatorBox.addItem(Bundle.getMessage("LogicOR"));
// initialize table of state variables
_variableTableModel = new VariableTableModel();
JTable variableTable = new JTable(_variableTableModel);
variableTable.setRowHeight(_notOperatorBox.getPreferredSize().height);
variableTable.setRowSelectionAllowed(false);
int rowHeight = variableTable.getRowHeight();
TableColumnModel variableColumnModel = variableTable.getColumnModel();
TableColumn rowColumn = variableColumnModel.getColumn(VariableTableModel.ROWNUM_COLUMN);
rowColumn.setResizable(false);
rowColumn.setMaxWidth(new JTextField(3).getPreferredSize().width);
TableColumn andColumn = variableColumnModel.getColumn(VariableTableModel.AND_COLUMN);
andColumn.setResizable(false);
andColumn.setCellEditor(new DefaultCellEditor(_andOperatorBox));
andColumn.setMaxWidth(_andOperatorBox.getPreferredSize().width - 5);
TableColumn notColumn = variableColumnModel.getColumn(VariableTableModel.NOT_COLUMN);
notColumn.setCellEditor(new DefaultCellEditor(_notOperatorBox));
notColumn.setMaxWidth(_notOperatorBox.getPreferredSize().width - 5);
notColumn.setResizable(false);
TableColumn descColumn = variableColumnModel.getColumn(VariableTableModel.DESCRIPTION_COLUMN);
descColumn.setPreferredWidth(300);
descColumn.setMinWidth(200);
descColumn.setResizable(true);
TableColumn stateColumn = variableColumnModel.getColumn(VariableTableModel.STATE_COLUMN);
stateColumn.setResizable(true);
stateColumn.setMinWidth(50);
stateColumn.setMaxWidth(80);
TableColumn triggerColumn = variableColumnModel.getColumn(VariableTableModel.TRIGGERS_COLUMN);
triggerColumn.setResizable(true);
triggerColumn.setMinWidth(30);
triggerColumn.setMaxWidth(80);
TableColumn editColumn = variableColumnModel.getColumn(VariableTableModel.EDIT_COLUMN);
ButtonRenderer buttonRenderer = new ButtonRenderer();
variableTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
variableTable.setDefaultEditor(JButton.class, buttonEditor);
JButton testButton = new JButton("XXXXXX");
variableTable.setRowHeight(testButton.getPreferredSize().height);
editColumn.setMinWidth(testButton.getPreferredSize().width);
editColumn.setMaxWidth(testButton.getPreferredSize().width);
editColumn.setResizable(false);
TableColumn deleteColumn = variableColumnModel.getColumn(VariableTableModel.DELETE_COLUMN);
// ButtonRenderer and TableCellEditor already set
deleteColumn.setMinWidth(testButton.getPreferredSize().width);
deleteColumn.setMaxWidth(testButton.getPreferredSize().width);
deleteColumn.setResizable(false);
// add a scroll pane
JScrollPane variableTableScrollPane = new JScrollPane(variableTable);
Dimension dim = variableTable.getPreferredSize();
dim.height = 7 * rowHeight;
variableTableScrollPane.getViewport().setPreferredSize(dim);
logicPanel.add(variableTableScrollPane);
// set up state variable buttons and logic
JPanel panel42 = new JPanel();
panel42.setLayout(new FlowLayout());
// Add State Variable
JButton addVariableButton = new JButton(rbx.getString("AddVariableButton"));
panel42.add(addVariableButton);
addVariableButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addVariablePressed(e);
}
});
addVariableButton.setToolTipText(rbx.getString("AddVariableButtonHint"));
JButton checkVariableButton = new JButton(rbx.getString("CheckVariableButton"));
panel42.add(checkVariableButton);
checkVariableButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkVariablePressed(e);
}
});
checkVariableButton.setToolTipText(rbx.getString("CheckVariableButtonHint"));
logicPanel.add(panel42);
// logic type area
_operatorBox = new JComboBox<String>(new String[] { Bundle.getMessage("LogicAND"), Bundle.getMessage("LogicOR"), Bundle.getMessage("LogicMixed") });
JPanel typePanel = makeEditPanel(_operatorBox, "LabelLogicType", "TypeLogicHint");
_operatorBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
logicTypeChanged(e);
}
});
_operatorBox.setSelectedIndex(_logicType - 1);
logicPanel.add(typePanel);
logicPanel.add(Box.createHorizontalStrut(STRUT));
Border logicPanelBorder = BorderFactory.createEtchedBorder();
Border logicPanelTitled = BorderFactory.createTitledBorder(logicPanelBorder, rbx.getString("TitleLogicalExpression") + " ");
logicPanel.setBorder(logicPanelTitled);
contentPane.add(logicPanel);
// End of Logic Expression Section
JPanel triggerPanel = new JPanel();
triggerPanel.setLayout(new BoxLayout(triggerPanel, BoxLayout.Y_AXIS));
ButtonGroup tGroup = new ButtonGroup();
_triggerOnChangeButton = new JRadioButton(rbx.getString("triggerOnChange"));
_triggerOnChangeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
_actionTableModel.fireTableDataChanged();
}
});
tGroup.add(_triggerOnChangeButton);
triggerPanel.add(_triggerOnChangeButton);
JRadioButton triggerOnAny = new JRadioButton(rbx.getString("triggerOnAny"));
triggerOnAny.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
_actionTableModel.fireTableDataChanged();
}
});
tGroup.add(triggerOnAny);
triggerPanel.add(triggerOnAny);
triggerOnAny.setSelected(true);
JPanel trigPanel = new JPanel();
trigPanel.add(triggerPanel);
contentPane.add(trigPanel);
_triggerOnChangeButton.setSelected(_curConditional.getTriggerOnChange());
// add Action Consequents Section
JPanel conseqentPanel = new JPanel();
conseqentPanel.setLayout(new BoxLayout(conseqentPanel, BoxLayout.Y_AXIS));
JPanel actTitle = new JPanel();
actTitle.setLayout(new FlowLayout());
actTitle.add(new JLabel(rbx.getString("ActionTableTitle")));
conseqentPanel.add(actTitle);
// set up action consequents table
_actionTableModel = new ActionTableModel();
JTable actionTable = new JTable(_actionTableModel);
actionTable.setRowSelectionAllowed(false);
actionTable.setRowHeight(testButton.getPreferredSize().height);
JPanel actionPanel = new JPanel();
actionPanel.setLayout(new BoxLayout(actionPanel, BoxLayout.Y_AXIS));
JPanel actionTitle = new JPanel();
actionTitle.setLayout(new FlowLayout());
conseqentPanel.add(actionPanel);
TableColumnModel actionColumnModel = actionTable.getColumnModel();
TableColumn descriptionColumn = actionColumnModel.getColumn(ActionTableModel.DESCRIPTION_COLUMN);
descriptionColumn.setResizable(true);
descriptionColumn.setPreferredWidth(600);
descriptionColumn.setMinWidth(300);
//descriptionColumn.setMaxWidth(760);
TableColumn actionEditColumn = actionColumnModel.getColumn(ActionTableModel.EDIT_COLUMN);
// ButtonRenderer already exists
actionTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor editButEditor = new ButtonEditor(new JButton());
actionTable.setDefaultEditor(JButton.class, editButEditor);
actionEditColumn.setMinWidth(testButton.getPreferredSize().width);
actionEditColumn.setMaxWidth(testButton.getPreferredSize().width);
actionEditColumn.setResizable(false);
TableColumn actionDeleteColumn = actionColumnModel.getColumn(ActionTableModel.DELETE_COLUMN);
// ButtonRenderer and TableCellEditor already set
actionDeleteColumn.setMinWidth(testButton.getPreferredSize().width);
actionDeleteColumn.setMaxWidth(testButton.getPreferredSize().width);
actionDeleteColumn.setResizable(false);
// add a scroll pane
JScrollPane actionTableScrollPane = new JScrollPane(actionTable);
dim = actionTableScrollPane.getPreferredSize();
dim.height = 7 * rowHeight;
actionTableScrollPane.getViewport().setPreferredSize(dim);
conseqentPanel.add(actionTableScrollPane);
// add action buttons to Action Section
JPanel panel43 = new JPanel();
panel43.setLayout(new FlowLayout());
JButton addActionButton = new JButton(rbx.getString("addActionButton"));
panel43.add(addActionButton);
addActionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addActionPressed(e);
}
});
addActionButton.setToolTipText(rbx.getString("addActionButtonHint"));
conseqentPanel.add(panel43);
// - Reorder action button
JButton reorderButton = new JButton(rbx.getString("ReorderButton"));
panel43.add(reorderButton);
reorderButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
reorderActionPressed(e);
}
});
reorderButton.setToolTipText(rbx.getString("ReorderButtonHint"));
conseqentPanel.add(panel43);
Border conseqentPanelBorder = BorderFactory.createEtchedBorder();
Border conseqentPanelTitled = BorderFactory.createTitledBorder(conseqentPanelBorder, rbx.getString("TitleAction"));
conseqentPanel.setBorder(conseqentPanelTitled);
contentPane.add(conseqentPanel);
// End of Action Consequents Section
// Bottom Buttons - Update Conditional
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
JButton updateConditional = new JButton(rbx.getString("UpdateConditionalButton"));
panel5.add(updateConditional);
updateConditional.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateConditionalPressed(e);
}
});
updateConditional.setToolTipText(rbx.getString("UpdateConditionalButtonHint"));
// Cancel
JButton cancelConditional = new JButton(Bundle.getMessage("ButtonCancel"));
panel5.add(cancelConditional);
cancelConditional.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelConditionalPressed(e);
}
});
cancelConditional.setToolTipText(rbx.getString("CancelConditionalButtonHint"));
// Delete Conditional
JButton deleteConditional = new JButton(Bundle.getMessage("ButtonDelete"));
panel5.add(deleteConditional);
deleteConditional.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteConditionalPressed(null);
}
});
deleteConditional.setToolTipText(rbx.getString("DeleteConditionalButtonHint"));
contentPane.add(panel5);
}
// setup window closing listener
editConditionalFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
cancelConditionalPressed(null);
}
});
// initialize state variable table
_variableTableModel.fireTableDataChanged();
// initialize action variables
_actionTableModel.fireTableDataChanged();
editConditionalFrame.pack();
editConditionalFrame.setVisible(true);
inEditConditionalMode = true;
// update variables to their current states
checkVariablePressed(null);
}
use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class TransitTableAction method addEditActionsPressed.
private void addEditActionsPressed(int r) {
activeRow = r;
if (actionTableModel != null) {
actionTableModel.fireTableStructureChanged();
}
if (actionTableFrame == null) {
actionTableFrame = new JmriJFrame(rbx.getString("TitleViewActions"));
actionTableFrame.addHelpMenu("package.jmri.jmrit.beantable.ViewSpecialActions", true);
actionTableFrame.setLocation(50, 60);
Container contentPane = actionTableFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel sectionNameLabel = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanNameSection")));
panel1.add(sectionNameLabel);
panel1.add(fixedSectionLabel);
contentPane.add(panel1);
// add table of Actions
JPanel pctSpace = new JPanel();
pctSpace.setLayout(new FlowLayout());
pctSpace.add(new JLabel(" "));
contentPane.add(pctSpace);
JPanel pct = new JPanel();
// initialize table of actions
actionTableModel = new SpecialActionTableModel();
JTable actionTable = new JTable(actionTableModel);
actionTable.setRowSelectionAllowed(false);
actionTable.setPreferredScrollableViewportSize(new java.awt.Dimension(750, 200));
TableColumnModel actionColumnModel = actionTable.getColumnModel();
TableColumn whenColumn = actionColumnModel.getColumn(SpecialActionTableModel.WHEN_COLUMN);
whenColumn.setResizable(true);
whenColumn.setMinWidth(270);
whenColumn.setMaxWidth(300);
TableColumn whatColumn = actionColumnModel.getColumn(SpecialActionTableModel.WHAT_COLUMN);
whatColumn.setResizable(true);
whatColumn.setMinWidth(290);
whatColumn.setMaxWidth(350);
TableColumn editColumn = actionColumnModel.getColumn(SpecialActionTableModel.EDIT_COLUMN);
// install button renderer and editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
actionTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
actionTable.setDefaultEditor(JButton.class, buttonEditor);
JButton testButton = new JButton(Bundle.getMessage("ButtonDelete"));
actionTable.setRowHeight(testButton.getPreferredSize().height);
editColumn.setResizable(false);
editColumn.setMinWidth(testButton.getPreferredSize().width);
TableColumn removeColumn = actionColumnModel.getColumn(SpecialActionTableModel.REMOVE_COLUMN);
removeColumn.setMinWidth(testButton.getPreferredSize().width);
removeColumn.setResizable(false);
JScrollPane actionTableScrollPane = new JScrollPane(actionTable);
pct.add(actionTableScrollPane, BorderLayout.CENTER);
contentPane.add(pct);
pct.setVisible(true);
// add view action panel buttons
JPanel but = new JPanel();
but.setLayout(new BoxLayout(but, BoxLayout.Y_AXIS));
JPanel panel4 = new JPanel();
panel4.setLayout(new FlowLayout());
JButton newActionButton = new JButton(rbx.getString("ButtonAddNewAction"));
panel4.add(newActionButton);
newActionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
newActionPressed(e);
}
});
newActionButton.setToolTipText(rbx.getString("NewActionButtonHint"));
JButton doneButton = new JButton(Bundle.getMessage("ButtonDone"));
panel4.add(doneButton);
doneButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doneWithActionsPressed(e);
}
});
doneButton.setToolTipText(rbx.getString("DoneButtonHint"));
but.add(panel4);
contentPane.add(but);
}
fixedSectionLabel.setText(getSectionNameByRow(r) + " " + rbx.getString("SequenceAbbrev") + ": " + sequence[r]);
actionTableFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
if (actionTableFrame != null) {
actionTableFrame.setVisible(false);
actionTableFrame.dispose();
actionTableFrame = null;
}
if (addEditActionFrame != null) {
addEditActionFrame.setVisible(false);
addEditActionFrame.dispose();
addEditActionFrame = null;
}
}
});
actionTableFrame.pack();
actionTableFrame.setVisible(true);
}
use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class ConsistDataModel method initTable.
void initTable(JTable ConsistTable) {
// Install the button handlers for the Delete Buttons
TableColumnModel tcm = ConsistTable.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(DELCOLUMN).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
tcm.getColumn(DELCOLUMN).setCellEditor(buttonEditor);
}
use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class WarrantTableFrame method initComponents.
/**
* By default, Swing components should be created an installed in this
* method, rather than in the ctor itself.
*/
@Override
public void initComponents() throws Exception {
//Casts at getTableCellEditorComponent() now fails with 3.0 ??
JTable table = new JTable(_model);
ComboBoxCellEditor comboEd;
TableRowSorter<WarrantTableModel> sorter = new TableRowSorter<>(_model);
comboEd = new ComboBoxCellEditor(new JComboBox<>());
table.setRowSorter(sorter);
// Use XTableColumnModel so we can control which columns are visible
XTableColumnModel tcm = new XTableColumnModel();
table.setColumnModel(tcm);
table.getTableHeader().setReorderingAllowed(true);
table.createDefaultColumnsFromModel();
_model.addHeaderListener(table);
table.setDefaultRenderer(Boolean.class, new ButtonRenderer());
table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
JComboBox<String> box = new JComboBox<>(controls);
box.setFont(new Font(null, Font.PLAIN, 12));
table.getColumnModel().getColumn(WarrantTableModel.CONTROL_COLUMN).setCellEditor(new DefaultCellEditor(box));
table.getColumnModel().getColumn(WarrantTableModel.ROUTE_COLUMN).setCellEditor(comboEd);
table.getColumnModel().getColumn(WarrantTableModel.ALLOCATE_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.ALLOCATE_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.DEALLOC_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.DEALLOC_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.SET_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.SET_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.AUTO_RUN_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.AUTO_RUN_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.MANUAL_RUN_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.MANUAL_RUN_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.EDIT_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.EDIT_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.DELETE_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.DELETE_COLUMN).setCellRenderer(new ButtonRenderer());
//table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
for (int i = 0; i < _model.getColumnCount(); i++) {
int width = _model.getPreferredWidth(i);
table.getColumnModel().getColumn(i).setPreferredWidth(width);
}
tcm.setColumnVisible(tcm.getColumnByModelIndex(WarrantTableModel.MANUAL_RUN_COLUMN), false);
_rowHeight = box.getPreferredSize().height;
table.setRowHeight(_rowHeight);
table.setDragEnabled(true);
table.setTransferHandler(new jmri.util.DnDTableExportHandler());
_tablePane = new JScrollPane(table);
JPanel tablePanel = new JPanel();
tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.Y_AXIS));
tablePanel.add(Box.createVerticalGlue());
JLabel title = new JLabel(Bundle.getMessage("ShowWarrants"));
tablePanel.add(title);
tablePanel.add(_tablePane);
JPanel bottom = new JPanel();
JPanel panel = new JPanel();
JButton nxButton = new JButton(Bundle.getMessage("CreateNXWarrant"));
nxButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nxAction();
}
});
panel.add(nxButton);
panel.add(Box.createGlue());
panel.add(new JLabel("status"));
_status.addMouseListener(this);
_status.setBackground(Color.white);
_status.setFont(_status.getFont().deriveFont(Font.BOLD));
_status.setEditable(false);
setStatusText(BLANK.substring(0, 90), null, false);
panel.add(_status);
JButton haltAllButton = new JButton(Bundle.getMessage("HaltAllTrains"));
haltAllButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
haltAllAction();
}
});
haltAllButton.setForeground(Color.RED);
panel.add(Box.createGlue());
panel.add(haltAllButton);
///
bottom.add(panel);
tablePanel.add(bottom);
addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
dispose();
}
});
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
fileMenu.add(new jmri.configurexml.SaveMenu());
menuBar.add(fileMenu);
JMenu warrantMenu = new JMenu(Bundle.getMessage("MenuWarrant"));
warrantMenu.add(new AbstractAction(Bundle.getMessage("ConcatWarrants")) {
@Override
public void actionPerformed(ActionEvent e) {
concatMenuAction();
}
});
warrantMenu.add(new jmri.jmrit.logix.WarrantTableAction("CreateWarrant"));
warrantMenu.add(WarrantTableAction._trackerTable);
warrantMenu.add(new AbstractAction(Bundle.getMessage("CreateNXWarrant")) {
@Override
public void actionPerformed(ActionEvent e) {
nxAction();
}
});
warrantMenu.add(WarrantTableAction.makeLogMenu());
menuBar.add(warrantMenu);
setJMenuBar(menuBar);
addHelpMenu("package.jmri.jmrit.logix.WarrantTable", true);
getContentPane().add(tablePanel);
// setLocation(50,0);
pack();
}
use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class AutomationsTableModel method initTable.
protected void initTable(AutomationsTableFrame frame, JTable table) {
_table = table;
// Install the button handlers
TableColumnModel tcm = table.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(RUN_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(RUN_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(EDIT_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDIT_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(200);
table.getColumnModel().getColumn(COMMENT_COLUMN).setPreferredWidth(350);
table.getColumnModel().getColumn(ACTION_COLUMN).setPreferredWidth(250);
table.getColumnModel().getColumn(STATUS_COLUMN).setPreferredWidth(90);
table.getColumnModel().getColumn(RUN_COLUMN).setPreferredWidth(90);
table.getColumnModel().getColumn(EDIT_COLUMN).setPreferredWidth(70);
table.getColumnModel().getColumn(DELETE_COLUMN).setPreferredWidth(90);
frame.loadTableDetails(table);
}
Aggregations