use of jmri.util.table.ButtonEditor 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.ButtonEditor 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.ButtonEditor 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.ButtonEditor in project JMRI by JMRI.
the class AddEntryExitPairPanel method setColumnToHoldButton.
/**
* Service method to set up a column so that it will hold a button for it's
* values.
*
* @param table the table
* @param column the column
* @param sample Typical button, used for size
*/
protected 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) + 4);
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class LocoIOPanel method initComponents.
@Override
public void initComponents(LocoNetSystemConnectionMemo memo) {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
ln = memo.getLnTrafficController();
// creating the table (done here to ensure order OK)
data = new LocoIOData(Integer.valueOf(addrField.getText(), 16).intValue(), Integer.valueOf(subAddrField.getText(), 16).intValue(), memo.getLnTrafficController());
model = new LocoIOTableModel(data);
table = new JTable(model);
scroll = new JScrollPane(table);
data.addPropertyChangeListener(this);
// have to shut off autoResizeMode to get horizontal scroll to work (JavaSwing p 541)
// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setShowHorizontalLines(true);
table.setAutoCreateColumnsFromModel(true);
TableColumnModel tcm = table.getColumnModel();
// install a ComboBox editor on the OnMode column
JComboBox<String> comboOnBox = new JComboBox<String>(data.getLocoIOModeList().getValidModes());
comboOnBox.setEditable(true);
DefaultCellEditor modeEditor = new DefaultCellEditor(comboOnBox);
tcm.getColumn(LocoIOTableModel.MODECOLUMN).setCellEditor(modeEditor);
// install a button renderer & editor in the Read, Write and Compare columns
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(LocoIOTableModel.READCOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(LocoIOTableModel.WRITECOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(LocoIOTableModel.CAPTURECOLUMN).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
tcm.getColumn(LocoIOTableModel.READCOLUMN).setCellEditor(buttonEditor);
tcm.getColumn(LocoIOTableModel.WRITECOLUMN).setCellEditor(buttonEditor);
tcm.getColumn(LocoIOTableModel.CAPTURECOLUMN).setCellEditor(buttonEditor);
// ensure the table rows, columns have enough room for buttons and comboBox contents
table.setRowHeight(new JButton("Capture").getPreferredSize().height);
for (int col = 0; col < LocoIOTableModel.HIGHESTCOLUMN; col++) {
table.getColumnModel().getColumn(col).setPreferredWidth(model.getPreferredWidth(col));
}
// A pane for SV0, SV1, SV2, the board sub address and the PIC version
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
p1.add(new JLabel("LocoIO address: 0x"));
addrField.setMaximumSize(addrField.getPreferredSize());
subAddrField.setMaximumSize(subAddrField.getPreferredSize());
p1.add(addrField);
p1.add(new JLabel("/"));
p1.add(subAddrField);
// -------------------
p1.add(Box.createGlue());
probeButton = new JButton("Probe");
probeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
data.setLIOVersion("<Not found>");
LocoIO.probeLocoIOs(ln);
}
});
p1.add(probeButton);
// -------------------
p1.add(Box.createGlue());
readAllButton = new JButton("Read All");
readAllButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
data.readAll();
}
});
p1.add(readAllButton);
writeAllButton = new JButton("Write All");
writeAllButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
data.writeAll();
}
});
p1.add(writeAllButton);
// -------------------
p1.add(Box.createGlue());
addrSetButton = new JButton("Set address");
p1.add(addrSetButton);
addrSetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
addrSet();
}
});
// -------------------
p1.add(Box.createGlue());
/*
openButton = new JButton("Load...");
openButton.setEnabled(false);
p1.add(openButton);
saveButton = new JButton("Save...");
saveButton.setEnabled(false);
p1.add(saveButton);
*/
JPanel p2 = new JPanel();
p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));
p2.add(new JLabel("Locobuffer rev: "));
p2.add(locobuffer);
// -------------------
p2.add(Box.createGlue());
p2.add(new JLabel("Status: "));
p2.add(status);
// -------------------
p2.add(Box.createGlue());
p2.add(new JLabel("LocoIO Firmware rev: "));
p2.add(firmware);
JPanel p3 = new JPanel();
p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
p3.add(p1);
p3.add(table);
add(p3);
add(p2);
// updating the Board address needs to be conveyed to the table
ActionListener al4UnitAddress = new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
try {
data.setUnitAddress(Integer.valueOf(addrField.getText(), 16).intValue(), Integer.valueOf(subAddrField.getText(), 16).intValue());
} catch (NullPointerException e) {
// NOI18N
log.error("Caught NullPointerException", e);
}
}
};
FocusListener fl4UnitAddress = new FocusListener() {
@Override
public void focusGained(FocusEvent event) {
}
@Override
public void focusLost(FocusEvent event) {
try {
data.setUnitAddress(Integer.valueOf(addrField.getText(), 16).intValue(), Integer.valueOf(subAddrField.getText(), 16).intValue());
} catch (NullPointerException e) {
// NOI18N
log.error("Caught NullPointerException", e);
}
}
};
addrField.addActionListener(al4UnitAddress);
subAddrField.addActionListener(al4UnitAddress);
addrField.addFocusListener(fl4UnitAddress);
subAddrField.addFocusListener(fl4UnitAddress);
try {
data.setUnitAddress(0x51, 0x00);
} catch (NullPointerException e) {
// NOI18N
log.error("Caught NullPointerException", e);
}
}
Aggregations