use of java.awt.FlowLayout in project JMRI by JMRI.
the class SignalGroupSubTableAction method editHead.
/**
* Open an editor to set the details of a Signal Head as part of a Signal Group.
* Called when user clicks the Edit button for a Head in the Add/Edit Signal Group pane.
* @see SignalGroupTableAction#signalHeadEditPressed(int) SignalGroupTableAction.signalHeadEditPressed
* @param g Parent Signal Head
* @param headName System or User Name of this Signal Head
*/
void editHead(SignalGroup g, String headName) {
curSignalGroup = g;
curHeadName = headName;
curSignalHead = jmri.InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(curHeadName);
// shows i18n strings from signal head definition
_OnAppearance = new JComboBox<String>(curSignalHead.getValidStateNames());
_OffAppearance = new JComboBox<String>(curSignalHead.getValidStateNames());
_systemName = new JLabel(headName);
_systemName.setVisible(true);
jmri.TurnoutManager tm = InstanceManager.turnoutManagerInstance();
List<String> systemNameList = tm.getSystemNameList();
_turnoutList = new ArrayList<SignalGroupTurnout>(systemNameList.size());
Iterator<String> iter = systemNameList.iterator();
while (iter.hasNext()) {
String systemName = iter.next();
String userName = tm.getBySystemName(systemName).getUserName();
_turnoutList.add(new SignalGroupTurnout(systemName, userName));
}
jmri.SensorManager sm = InstanceManager.sensorManagerInstance();
systemNameList = sm.getSystemNameList();
_sensorList = new ArrayList<SignalGroupSensor>(systemNameList.size());
iter = systemNameList.iterator();
while (iter.hasNext()) {
String systemName = iter.next();
Sensor sen = sm.getBySystemName(systemName);
if (sen != null) {
String userName = sen.getUserName();
_sensorList.add(new SignalGroupSensor(systemName, userName));
}
}
initializeIncludedList();
// Set up sub panel for editing of a Signal Group Signal Head item
if (addSubFrame == null) {
// create one if not yet available
addSubFrame = new JmriJFrame((Bundle.getMessage("EditSignalGroup") + " - " + Bundle.getMessage("BeanNameSignalHead")), false, true);
addSubFrame.addHelpMenu("package.jmri.jmrit.beantable.SignalGroupAddEdit", true);
addSubFrame.setLocation(100, 30);
addSubFrame.getContentPane().setLayout(new BoxLayout(addSubFrame.getContentPane(), BoxLayout.Y_AXIS));
Container contentPane = addSubFrame.getContentPane();
// add system name label
JPanel ps = new JPanel();
ps.setLayout(new FlowLayout());
ps.add(nameLabel);
ps.add(_systemName);
contentPane.add(ps);
// add user name label
JPanel pc = new JPanel();
pc.setLayout(new FlowLayout());
pc.add(signalOnStateLabel);
// comboBox to set On Appearance
pc.add(_OnAppearance);
_OnAppearance.setToolTipText(Bundle.getMessage("StateWhenMetTooltip"));
pc.add(spacer);
pc.add(signalOffStateLabel);
// comboBox to set On Appearance
pc.add(_OffAppearance);
_OffAppearance.setToolTipText(Bundle.getMessage("StateWhenNotMetTooltip"));
contentPane.add(pc);
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
p.add(userLabel);
contentPane.add(p);
// fill in info for the Signal Head being configured
if (curSignalHead.getClass().getName().contains("SingleTurnoutSignalHead")) {
jmri.implementation.SingleTurnoutSignalHead stsh = (jmri.implementation.SingleTurnoutSignalHead) InstanceManager.getDefault(jmri.SignalHeadManager.class).getByUserName(curHeadName);
// we may use a user name in the editing pane, so look for that first
if (stsh == null) {
stsh = (jmri.implementation.SingleTurnoutSignalHead) InstanceManager.getDefault(jmri.SignalHeadManager.class).getBySystemName(curHeadName);
// when user name is empty, get by user name
}
if (stsh != null) {
log.debug("SGsubTA #279 editHead: setting props for signal head {}", curHeadName);
if ((g.getHeadOnState(curSignalHead) == 0x00) && (g.getHeadOffState(curSignalHead) == 0x00)) {
g.setHeadOnState(curSignalHead, stsh.getOnAppearance());
g.setHeadOffState(curSignalHead, stsh.getOffAppearance());
}
} else {
// nothing found
log.error("Failed to get signal head object named {}", curHeadName);
}
}
setSignalHeadStateBox(g.getHeadOnState(curSignalHead), _OnAppearance);
setSignalHeadStateBox(g.getHeadOffState(curSignalHead), _OffAppearance);
// add Turnout Display Choice
JPanel py = new JPanel();
py.add(new JLabel(Bundle.getMessage("Show")));
selGroup = new ButtonGroup();
allButton = new JRadioButton(Bundle.getMessage("All"), true);
selGroup.add(allButton);
py.add(allButton);
allButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Setup for display of all Turnouts, if needed
if (!showAll) {
showAll = true;
_SignalGroupTurnoutModel.fireTableDataChanged();
_SignalGroupSensorModel.fireTableDataChanged();
}
}
});
includedButton = new JRadioButton(Bundle.getMessage("Included"), false);
selGroup.add(includedButton);
py.add(includedButton);
includedButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Setup for display of included Turnouts only, if needed
if (showAll) {
showAll = false;
initializeIncludedList();
_SignalGroupTurnoutModel.fireTableDataChanged();
_SignalGroupSensorModel.fireTableDataChanged();
}
}
});
py.add(new JLabel(" " + Bundle.getMessage("_and_", Bundle.getMessage("Turnouts"), Bundle.getMessage("Sensors"))));
contentPane.add(py);
// add turnout table
p2xt = new JPanel();
JPanel p2xtSpace = new JPanel();
p2xtSpace.setLayout(new BoxLayout(p2xtSpace, BoxLayout.Y_AXIS));
p2xtSpace.add(new JLabel("XXX"));
p2xt.add(p2xtSpace);
JPanel p21t = new JPanel();
p21t.setLayout(new BoxLayout(p21t, BoxLayout.Y_AXIS));
p21t.add(new JLabel(Bundle.getMessage("SelectInGroup", Bundle.getMessage("Turnouts"))));
p2xt.add(p21t);
_SignalGroupTurnoutModel = new SignalGroupTurnoutModel();
JTable SignalGroupTurnoutTable = new JTable(_SignalGroupTurnoutModel);
TableRowSorter<SignalGroupTurnoutModel> sgtSorter = new TableRowSorter<>(_SignalGroupTurnoutModel);
sgtSorter.setComparator(SignalGroupTurnoutModel.SNAME_COLUMN, new SystemNameComparator());
RowSorterUtil.setSortOrder(sgtSorter, SignalGroupTurnoutModel.SNAME_COLUMN, SortOrder.ASCENDING);
SignalGroupTurnoutTable.setRowSorter(sgtSorter);
SignalGroupTurnoutTable.setRowSelectionAllowed(false);
SignalGroupTurnoutTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 80));
ROW_HEIGHT = SignalGroupTurnoutTable.getRowHeight();
JComboBox<String> stateTCombo = new JComboBox<String>();
stateTCombo.addItem(SET_TO_CLOSED);
stateTCombo.addItem(SET_TO_THROWN);
TableColumnModel SignalGroupTurnoutColumnModel = SignalGroupTurnoutTable.getColumnModel();
TableColumn includeColumnT = SignalGroupTurnoutColumnModel.getColumn(SignalGroupTurnoutModel.INCLUDE_COLUMN);
includeColumnT.setResizable(false);
includeColumnT.setMinWidth(50);
includeColumnT.setMaxWidth(60);
TableColumn sNameColumnT = SignalGroupTurnoutColumnModel.getColumn(SignalGroupTurnoutModel.SNAME_COLUMN);
sNameColumnT.setResizable(true);
sNameColumnT.setMinWidth(75);
sNameColumnT.setMaxWidth(95);
TableColumn uNameColumnT = SignalGroupTurnoutColumnModel.getColumn(SignalGroupTurnoutModel.UNAME_COLUMN);
uNameColumnT.setResizable(true);
uNameColumnT.setMinWidth(210);
uNameColumnT.setMaxWidth(260);
TableColumn stateColumnT = SignalGroupTurnoutColumnModel.getColumn(SignalGroupTurnoutModel.STATE_COLUMN);
stateColumnT.setCellEditor(new DefaultCellEditor(stateTCombo));
stateColumnT.setResizable(false);
stateColumnT.setMinWidth(90);
stateColumnT.setMaxWidth(100);
_SignalGroupTurnoutScrollPane = new JScrollPane(SignalGroupTurnoutTable);
p2xt.add(_SignalGroupTurnoutScrollPane, BorderLayout.CENTER);
contentPane.add(p2xt);
p2xt.setVisible(true);
JPanel po = new JPanel();
po.setLayout(new FlowLayout());
JLabel operLabel = new JLabel(Bundle.getMessage("ChooseOrAnd"));
po.add(operLabel);
po.add(_SensorTurnoutOper);
contentPane.add(po);
// add sensor table
p2xs = new JPanel();
JPanel p2xsSpace = new JPanel();
p2xsSpace.setLayout(new BoxLayout(p2xsSpace, BoxLayout.Y_AXIS));
p2xsSpace.add(new JLabel("XXX"));
p2xs.add(p2xsSpace);
JPanel p21s = new JPanel();
p21s.setLayout(new BoxLayout(p21s, BoxLayout.Y_AXIS));
p21s.add(new JLabel(Bundle.getMessage("SelectInGroup", Bundle.getMessage("Sensors"))));
p2xs.add(p21s);
_SignalGroupSensorModel = new SignalGroupSensorModel();
JTable SignalGroupSensorTable = new JTable(_SignalGroupSensorModel);
TableRowSorter<SignalGroupSensorModel> sgsSorter = new TableRowSorter<>(_SignalGroupSensorModel);
sgsSorter.setComparator(SignalGroupSensorModel.SNAME_COLUMN, new SystemNameComparator());
RowSorterUtil.setSortOrder(sgsSorter, SignalGroupSensorModel.SNAME_COLUMN, SortOrder.ASCENDING);
SignalGroupSensorTable.setRowSorter(sgsSorter);
SignalGroupSensorTable.setRowSelectionAllowed(false);
SignalGroupSensorTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 80));
JComboBox<String> stateSCombo = new JComboBox<String>();
stateSCombo.addItem(SET_TO_ACTIVE);
stateSCombo.addItem(SET_TO_INACTIVE);
TableColumnModel SignalGroupSensorColumnModel = SignalGroupSensorTable.getColumnModel();
TableColumn includeColumnS = SignalGroupSensorColumnModel.getColumn(SignalGroupSensorModel.INCLUDE_COLUMN);
includeColumnS.setResizable(false);
includeColumnS.setMinWidth(50);
includeColumnS.setMaxWidth(60);
TableColumn sNameColumnS = SignalGroupSensorColumnModel.getColumn(SignalGroupSensorModel.SNAME_COLUMN);
sNameColumnS.setResizable(true);
sNameColumnS.setMinWidth(75);
sNameColumnS.setMaxWidth(95);
TableColumn uNameColumnS = SignalGroupSensorColumnModel.getColumn(SignalGroupSensorModel.UNAME_COLUMN);
uNameColumnS.setResizable(true);
uNameColumnS.setMinWidth(210);
uNameColumnS.setMaxWidth(260);
TableColumn stateColumnS = SignalGroupSensorColumnModel.getColumn(SignalGroupSensorModel.STATE_COLUMN);
stateColumnS.setCellEditor(new DefaultCellEditor(stateSCombo));
stateColumnS.setResizable(false);
stateColumnS.setMinWidth(90);
stateColumnS.setMaxWidth(100);
_SignalGroupSensorScrollPane = new JScrollPane(SignalGroupSensorTable);
p2xs.add(_SignalGroupSensorScrollPane, BorderLayout.CENTER);
contentPane.add(p2xs);
p2xs.setVisible(true);
// add notes panel
JPanel pa = new JPanel();
pa.setLayout(new BoxLayout(pa, BoxLayout.Y_AXIS));
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(status1);
pa.add(p1);
Border pBorder = BorderFactory.createEtchedBorder();
pa.setBorder(pBorder);
contentPane.add(pa);
// add buttons - Add SignalGroup button
JPanel pb = new JPanel();
pb.setLayout(new FlowLayout(FlowLayout.TRAILING));
// add Cancel button
pb.add(cancelButton);
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelSubPressed(e);
}
});
// add Update SignalGroup button
pb.add(updateSubButton);
updateSubButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateSubPressed(e, false);
}
});
updateSubButton.setToolTipText(Bundle.getMessage("TooltipUpdate"));
p2xtSpace.setVisible(false);
p2xsSpace.setVisible(false);
updateSubButton.setVisible(true);
contentPane.add(pb);
addSubFrame.pack();
}
// set listener for window closing
addSubFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
addSubFrame.setVisible(false);
cancelSubEdit();
_SignalGroupSensorModel.dispose();
_SignalGroupTurnoutModel.dispose();
}
});
addSubFrame.setVisible(true);
// add AND/OR choice box
setoperBox(curSignalGroup.getSensorTurnoutOper(curSignalHead), _SensorTurnoutOper);
setSignalHeadStateBox(curSignalGroup.getHeadOnState(curSignalHead), _OnAppearance);
setSignalHeadStateBox(curSignalGroup.getHeadOffState(curSignalHead), _OffAppearance);
int setRow = 0;
for (int i = _turnoutList.size() - 1; i >= 0; i--) {
SignalGroupTurnout turnout = _turnoutList.get(i);
Turnout tTurnout = turnout.getTurnout();
if (curSignalGroup.isTurnoutIncluded(curSignalHead, tTurnout)) {
turnout.setIncluded(true);
turnout.setState(curSignalGroup.getTurnoutState(curSignalHead, tTurnout));
setRow = i;
} else {
turnout.setIncluded(false);
turnout.setState(Turnout.CLOSED);
}
}
setRow -= 1;
if (setRow < 0) {
setRow = 0;
}
_SignalGroupTurnoutScrollPane.getVerticalScrollBar().setValue(setRow * ROW_HEIGHT);
_SignalGroupTurnoutModel.fireTableDataChanged();
for (int i = _sensorList.size() - 1; i >= 0; i--) {
SignalGroupSensor sensor = _sensorList.get(i);
Sensor tSensor = sensor.getSensor();
if (curSignalGroup.isSensorIncluded(curSignalHead, tSensor)) {
sensor.setIncluded(true);
sensor.setState(curSignalGroup.getSensorState(curSignalHead, tSensor));
setRow = i;
} else {
sensor.setIncluded(false);
sensor.setState(Sensor.INACTIVE);
}
}
status1.setText(updateInst);
updateSubButton.setVisible(true);
}
use of java.awt.FlowLayout in project JMRI by JMRI.
the class SectionTableAction method addEditPressed.
void addEditPressed() {
pref = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
if (addFrame == null) {
addFrame = new JmriJFrame(Bundle.getMessage("TitleAddSection"));
addFrame.addHelpMenu("package.jmri.jmrit.beantable.SectionAddEdit", true);
addFrame.getContentPane().setLayout(new BoxLayout(addFrame.getContentPane(), BoxLayout.Y_AXIS));
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
p.add(sysNameLabel);
p.add(sysNameFixed);
p.add(sysName);
p.add(_autoSystemName);
_autoSystemName.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
autoSystemName();
}
});
if (pref.getSimplePreferenceState(systemNameAuto)) {
_autoSystemName.setSelected(true);
}
sysName.setToolTipText(rbx.getString("SectionSystemNameHint"));
p.add(new JLabel(" "));
p.add(userNameLabel);
p.add(userName);
userName.setToolTipText(rbx.getString("SectionUserNameHint"));
addFrame.getContentPane().add(p);
JPanel pa = new JPanel();
pa.setLayout(new FlowLayout());
pa.add(generationStateLabel);
addFrame.getContentPane().add(pa);
addFrame.getContentPane().add(new JSeparator());
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
JPanel p11 = new JPanel();
p11.setLayout(new FlowLayout());
p11.add(new JLabel(rbx.getString("BlockTableMessage")));
p1.add(p11);
JPanel p12 = new JPanel();
// initialize table of blocks
blockTableModel = new BlockTableModel();
JTable blockTable = new JTable(blockTableModel);
blockTable.setRowSelectionAllowed(false);
blockTable.setPreferredScrollableViewportSize(new java.awt.Dimension(350, 100));
TableColumnModel blockColumnModel = blockTable.getColumnModel();
TableColumn sNameColumn = blockColumnModel.getColumn(BlockTableModel.SNAME_COLUMN);
sNameColumn.setResizable(true);
sNameColumn.setMinWidth(90);
sNameColumn.setMaxWidth(130);
TableColumn uNameColumn = blockColumnModel.getColumn(BlockTableModel.UNAME_COLUMN);
uNameColumn.setResizable(true);
uNameColumn.setMinWidth(210);
uNameColumn.setMaxWidth(260);
JScrollPane blockTableScrollPane = new JScrollPane(blockTable);
p12.add(blockTableScrollPane, BorderLayout.CENTER);
p1.add(p12);
JPanel p13 = new JPanel();
p13.setLayout(new FlowLayout());
p13.add(deleteBlocks = new JButton(rbx.getString("DeleteAllBlocksButton")));
deleteBlocks.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteBlocksPressed(e);
}
});
deleteBlocks.setToolTipText(rbx.getString("DeleteAllBlocksButtonHint"));
p13.add(new JLabel(" "));
p13.add(blockBox);
blockBox.setToolTipText(rbx.getString("BlockBoxHint"));
p13.add(addBlock = new JButton(rbx.getString("AddBlockButton")));
addBlock.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addBlockPressed(e);
}
});
addBlock.setToolTipText(rbx.getString("AddBlockButtonHint"));
p1.add(p13);
addFrame.getContentPane().add(p1);
addFrame.getContentPane().add(new JSeparator());
JPanel p31 = new JPanel();
p31.setLayout(new FlowLayout());
p31.add(new JLabel(rbx.getString("EntryPointTable")));
addFrame.getContentPane().add(p31);
JPanel p32 = new JPanel();
p32.setLayout(new FlowLayout());
entryPointOptions = new ButtonGroup();
p32.add(manually);
entryPointOptions.add(manually);
manually.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
manualEntryPoints = true;
}
});
manually.setToolTipText(rbx.getString("SetManuallyHint"));
p32.add(new JLabel(" "));
p32.add(automatic);
entryPointOptions.add(automatic);
automatic.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
manualEntryPoints = false;
}
});
automatic.setToolTipText(rbx.getString("SetAutomaticHint"));
p32.add(layoutEditorBox);
layoutEditorBox.setToolTipText(rbx.getString("LayoutEditorBoxHint"));
layoutEditorBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
layoutEditorSelectionChanged();
}
});
// djd debugging - temporarily hide these items until the automatic setting of entry point direction is ready
// addFrame.getContentPane().add(p32);
// end djd debugging
JPanel p33 = new JPanel();
// initialize table of entry points
entryPointTableModel = new EntryPointTableModel();
JTable entryPointTable = new JTable(entryPointTableModel);
entryPointTable.setRowSelectionAllowed(false);
// GT - 12-Oct-2009
entryPointTable.setPreferredScrollableViewportSize(new java.awt.Dimension(550, 100));
TableColumnModel entryPointColumnModel = entryPointTable.getColumnModel();
TableColumn fromBlockColumn = entryPointColumnModel.getColumn(EntryPointTableModel.BLOCK_COLUMN);
fromBlockColumn.setResizable(true);
fromBlockColumn.setMinWidth(250);
fromBlockColumn.setMaxWidth(310);
// GT - 12-Oct-2009 - start
TableColumn toBlockColumn = entryPointColumnModel.getColumn(EntryPointTableModel.TO_BLOCK_COLUMN);
toBlockColumn.setResizable(true);
toBlockColumn.setMinWidth(150);
toBlockColumn.setMaxWidth(210);
// GT - 12-Oct-2009 - end
JComboBox<String> directionCombo = new JComboBox<String>();
directionCombo.addItem(rbx.getString("SectionForward"));
directionCombo.addItem(rbx.getString("SectionReverse"));
directionCombo.addItem(Bundle.getMessage("BeanStateUnknown"));
TableColumn directionColumn = entryPointColumnModel.getColumn(EntryPointTableModel.DIRECTION_COLUMN);
directionColumn.setCellEditor(new DefaultCellEditor(directionCombo));
entryPointTable.setRowHeight(directionCombo.getPreferredSize().height);
directionColumn.setPreferredWidth(directionCombo.getPreferredSize().width);
directionColumn.setResizable(false);
JScrollPane entryPointTableScrollPane = new JScrollPane(entryPointTable);
p33.add(entryPointTableScrollPane, BorderLayout.CENTER);
addFrame.getContentPane().add(p33);
p33.setVisible(true);
JPanel p34 = new JPanel();
p34.setLayout(new FlowLayout());
p34.add(new JLabel(rbx.getString("DirectionNote")));
addFrame.getContentPane().add(p34);
addFrame.getContentPane().add(new JSeparator());
// set up for direction sensors
JPanel p20 = new JPanel();
p20.setLayout(new FlowLayout());
p20.add(new JLabel(rbx.getString("DirectionSensorLabel")));
addFrame.getContentPane().add(p20);
JPanel p21 = new JPanel();
p21.setLayout(new FlowLayout());
p21.add(new JLabel(rbx.getString("ForwardSensor")));
p21.add(forwardSensorField);
forwardSensorField.setToolTipText(rbx.getString("ForwardSensorHint"));
p21.add(new JLabel(" "));
p21.add(new JLabel(rbx.getString("ReverseSensor")));
p21.add(reverseSensorField);
reverseSensorField.setToolTipText(rbx.getString("ReverseSensorHint"));
addFrame.getContentPane().add(p21);
addFrame.getContentPane().add(new JSeparator());
// set up for stopping sensors
JPanel p40 = new JPanel();
p40.setLayout(new FlowLayout());
p40.add(new JLabel(rbx.getString("StoppingSensorLabel")));
addFrame.getContentPane().add(p40);
JPanel p41 = new JPanel();
p41.setLayout(new FlowLayout());
p41.add(new JLabel(rbx.getString("ForwardStopSensor")));
p41.add(forwardStopSensorField);
forwardStopSensorField.setToolTipText(rbx.getString("ForwardStopSensorHint"));
p41.add(new JLabel(" "));
p41.add(new JLabel(rbx.getString("ReverseStopSensor")));
p41.add(reverseStopSensorField);
reverseStopSensorField.setToolTipText(rbx.getString("ReverseStopSensorHint"));
addFrame.getContentPane().add(p41);
addFrame.getContentPane().add(new JSeparator());
// set up bottom buttons
JButton cancel = null;
JPanel pb = new JPanel();
pb.setLayout(new FlowLayout());
pb.add(cancel = new JButton(Bundle.getMessage("ButtonCancel")));
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelPressed(e);
}
});
cancel.setToolTipText(rbx.getString("CancelButtonHint"));
pb.add(create = new JButton(Bundle.getMessage("ButtonCreate")));
create.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
createPressed(e);
}
});
create.setToolTipText(rbx.getString("SectionCreateButtonHint"));
pb.add(update = new JButton(Bundle.getMessage("ButtonUpdate")));
update.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatePressed(e);
}
});
update.setToolTipText(rbx.getString("SectionUpdateButtonHint"));
addFrame.getContentPane().add(pb);
}
if (editMode) {
// setup for edit window
_autoSystemName.setVisible(false);
sysNameLabel.setEnabled(true);
create.setVisible(false);
update.setVisible(true);
sysName.setVisible(false);
sysNameFixed.setVisible(true);
initializeEditInformation();
} else {
// setup for create window
_autoSystemName.setVisible(true);
create.setVisible(true);
update.setVisible(false);
sysName.setVisible(true);
sysNameFixed.setVisible(false);
autoSystemName();
clearForCreate();
}
// initialize layout editor panels
if (initializeLayoutEditorCombo(layoutEditorBox)) {
manually.setVisible(true);
automatic.setVisible(true);
layoutEditorBox.setVisible(true);
} else {
manually.setVisible(false);
automatic.setVisible(false);
layoutEditorBox.setVisible(false);
}
// initialize block combo - first time
initializeBlockCombo();
addFrame.pack();
addFrame.setVisible(true);
}
use of java.awt.FlowLayout in project JMRI by JMRI.
the class AutoTrainsFrame method newTrainLine.
private void newTrainLine() {
int i = _JPanels.size();
final String s = "" + i;
newSeparator();
JPanel px = new JPanel();
px.setLayout(new FlowLayout());
_JPanels.add(px);
JLabel tLabel = new JLabel(" ");
px.add(tLabel);
px.add(tLabel);
_trainLabels.add(tLabel);
JButton tStop = new JButton(Bundle.getMessage("ResumeButton"));
px.add(tStop);
_stopButtons.add(tStop);
tStop.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stopResume(s);
}
});
JButton tManual = new JButton(Bundle.getMessage("ToManualButton"));
px.add(tManual);
_manualButtons.add(tManual);
tManual.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
manualAuto(s);
}
});
JButton tResumeAuto = new JButton(Bundle.getMessage("ResumeAutoButton"));
px.add(tResumeAuto);
_resumeAutoRunningButtons.add(tResumeAuto);
tResumeAuto.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resumeAutoOperation(s);
}
});
tResumeAuto.setVisible(false);
tResumeAuto.setToolTipText(Bundle.getMessage("ResumeAutoButtonHint"));
ButtonGroup directionGroup = new ButtonGroup();
JRadioButton fBut = new JRadioButton(Bundle.getMessage("ForwardRadio"));
px.add(fBut);
_forwardButtons.add(fBut);
fBut.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
directionButton(s);
}
});
directionGroup.add(fBut);
JRadioButton rBut = new JRadioButton(Bundle.getMessage("ReverseRadio"));
px.add(rBut);
_reverseButtons.add(rBut);
rBut.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
directionButton(s);
}
});
directionGroup.add(rBut);
JSlider sSlider = new JSlider(0, 100, 0);
px.add(sSlider);
_speedSliders.add(sSlider);
sSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int val = ((JSlider) (e.getSource())).getValue();
sliderChanged(s, val);
}
});
JLabel _throttle = new JLabel();
_throttle.setText("Speed Unknown");
_throttleStatus.add(_throttle);
px.add(_throttle);
contentPane.add(px);
}
use of java.awt.FlowLayout in project JMRI by JMRI.
the class OptionsMenu method optionWindowRequested.
private void optionWindowRequested(ActionEvent e) {
if (optionsFrame == null) {
optionsFrame = new JmriJFrame(Bundle.getMessage("MenuOptions"), false, true);
optionsFrame.addHelpMenu("package.jmri.jmrit.dispatcher.Options", true);
optionsPane = optionsFrame.getContentPane();
optionsPane.setLayout(new BoxLayout(optionsFrame.getContentPane(), BoxLayout.Y_AXIS));
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(useConnectivityCheckBox);
useConnectivityCheckBox.setToolTipText(Bundle.getMessage("UseConnectivityHint"));
p1.add(layoutEditorBox);
layoutEditorBox.setToolTipText(Bundle.getMessage("LayoutEditorHint"));
signalTypeBox = new JComboBox<String>(signalTypes);
p1.add(signalTypeBox);
signalTypeBox.setToolTipText(Bundle.getMessage("SignalTypeHint"));
optionsPane.add(p1);
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout());
ButtonGroup trainsGroup = new ButtonGroup();
p2.add(trainsFromRoster);
trainsFromRoster.setToolTipText(Bundle.getMessage("TrainsFromRosterHint"));
trainsGroup.add(trainsFromRoster);
ActionListener useRosterEntryListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (trainsFromRoster.isSelected()) {
rosterInBlockCheckBox.setEnabled(true);
if (nameInBlockCheckBox.isSelected() && e.getSource() == nameInBlockCheckBox) {
rosterInBlockCheckBox.setSelected(false);
} else if (rosterInBlockCheckBox.isSelected() && e.getSource() == rosterInBlockCheckBox) {
nameInBlockCheckBox.setSelected(false);
}
} else {
rosterInBlockCheckBox.setEnabled(false);
}
}
};
trainsFromRoster.addActionListener(useRosterEntryListener);
p2.add(new JLabel(" "));
p2.add(trainsFromTrains);
trainsFromTrains.setToolTipText(Bundle.getMessage("TrainsFromTrainsHint"));
trainsFromTrains.addActionListener(useRosterEntryListener);
trainsGroup.add(trainsFromTrains);
p2.add(new JLabel(" "));
p2.add(trainsFromUser);
trainsFromUser.setToolTipText(Bundle.getMessage("TrainsFromUserHint"));
trainsFromUser.addActionListener(useRosterEntryListener);
trainsGroup.add(trainsFromUser);
optionsPane.add(p2);
JPanel p3 = new JPanel();
p3.setLayout(new FlowLayout());
p3.add(detectionCheckBox);
detectionCheckBox.setToolTipText(Bundle.getMessage("DetectionBoxHint"));
optionsPane.add(p3);
JPanel p4 = new JPanel();
p4.setLayout(new FlowLayout());
p4.add(autoAllocateCheckBox);
autoAllocateCheckBox.setToolTipText(Bundle.getMessage("AutoAllocateBoxHint"));
optionsPane.add(p4);
JPanel p5 = new JPanel();
p5.setLayout(new FlowLayout());
p5.add(autoTurnoutsCheckBox);
autoTurnoutsCheckBox.setToolTipText(Bundle.getMessage("AutoTurnoutsBoxHint"));
optionsPane.add(p5);
JPanel p16 = new JPanel();
p16.setLayout(new FlowLayout());
p16.add(trustKnownTurnoutsCheckBox);
trustKnownTurnoutsCheckBox.setToolTipText(Bundle.getMessage("trustKnownTurnoutsHint"));
optionsPane.add(p16);
JPanel p6 = new JPanel();
p6.setLayout(new FlowLayout());
p6.add(shortNameCheckBox);
shortNameCheckBox.setToolTipText(Bundle.getMessage("ShortNameBoxHint"));
optionsPane.add(p6);
JPanel p7 = new JPanel();
p7.setLayout(new FlowLayout());
p7.add(nameInBlockCheckBox);
nameInBlockCheckBox.setToolTipText(Bundle.getMessage("NameInBlockBoxHint"));
nameInBlockCheckBox.addActionListener(useRosterEntryListener);
optionsPane.add(p7);
JPanel p7b = new JPanel();
p7b.setLayout(new FlowLayout());
p7b.add(rosterInBlockCheckBox);
rosterInBlockCheckBox.setToolTipText(Bundle.getMessage("RosterInBlockBoxHint"));
rosterInBlockCheckBox.addActionListener(useRosterEntryListener);
optionsPane.add(p7b);
JPanel p10 = new JPanel();
p10.setLayout(new FlowLayout());
p10.add(extraColorForAllocatedCheckBox);
extraColorForAllocatedCheckBox.setToolTipText(Bundle.getMessage("ExtraColorForAllocatedBoxHint"));
optionsPane.add(p10);
JPanel p11 = new JPanel();
p11.setLayout(new FlowLayout());
p11.add(nameInAllocatedBlockCheckBox);
nameInAllocatedBlockCheckBox.setToolTipText(Bundle.getMessage("NameInAllocatedBlockBoxHint"));
optionsPane.add(p11);
JPanel p13 = new JPanel();
p13.setLayout(new FlowLayout());
p13.add(supportVSDecoderCheckBox);
supportVSDecoderCheckBox.setToolTipText(Bundle.getMessage("SupportVSDecoderBoxHint"));
optionsPane.add(p13);
JPanel p8 = new JPanel();
initializeScaleCombo();
p8.add(new JLabel(Bundle.getMessage("LayoutScale") + ":"));
p8.add(layoutScaleBox);
layoutScaleBox.setToolTipText(Bundle.getMessage("ScaleBoxHint"));
optionsPane.add(p8);
JPanel p12 = new JPanel();
p12.setLayout(new FlowLayout());
p12.add(new JLabel(Bundle.getMessage("Units") + " "));
ButtonGroup scaleGroup = new ButtonGroup();
p12.add(scaleFeet);
scaleFeet.setToolTipText(Bundle.getMessage("ScaleFeetHint"));
scaleGroup.add(scaleFeet);
p12.add(new JLabel(" "));
p12.add(scaleMeters);
scaleMeters.setToolTipText(Bundle.getMessage("ScaleMetersHint"));
scaleGroup.add(scaleMeters);
optionsPane.add(p12);
JPanel p15 = new JPanel();
p15.setLayout(new FlowLayout());
p15.add(new JLabel(Bundle.getMessage("minThrottleInterval") + " :"));
NumberFormatter numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());
numberFormatter.setValueClass(Integer.class);
numberFormatter.setMinimum(20);
numberFormatter.setMaximum(1000);
minThrottleIntervalTextField = new JFormattedTextField(numberFormatter);
minThrottleIntervalTextField.setColumns(4);
minThrottleIntervalTextField.setValue(250);
minThrottleIntervalTextField.setToolTipText(Bundle.getMessage("minThrottleIntervalHint"));
p15.add(minThrottleIntervalTextField);
p15.add(new JLabel(Bundle.getMessage("ms")));
optionsPane.add(p15);
JPanel p17 = new JPanel();
p17.setLayout(new FlowLayout());
p17.add(new JLabel(Bundle.getMessage("fullRampTime") + " :"));
numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());
numberFormatter.setValueClass(Integer.class);
numberFormatter.setMinimum(1000);
numberFormatter.setMaximum(20000);
fullRampTimeTextField = new JFormattedTextField(numberFormatter);
fullRampTimeTextField.setColumns(4);
fullRampTimeTextField.setValue(5000);
fullRampTimeTextField.setToolTipText(Bundle.getMessage("fullRampTimeHint"));
p17.add(fullRampTimeTextField);
p17.add(new JLabel(Bundle.getMessage("ms")));
optionsPane.add(p17);
JPanel p14 = new JPanel();
p14.setLayout(new FlowLayout());
p14.add(openDispatcherWithPanel);
openDispatcherWithPanel.setToolTipText(Bundle.getMessage("OpenDispatcherWithPanelBoxHint"));
optionsPane.add(p14);
optionsPane.add(new JSeparator());
JPanel p9 = new JPanel();
p9.setLayout(new FlowLayout());
JButton cancelButton = null;
p9.add(cancelButton = new JButton(Bundle.getMessage("ButtonCancel")));
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelOptions(e);
}
});
cancelButton.setToolTipText(Bundle.getMessage("CancelButtonHint2"));
p9.add(new JLabel(" "));
JButton applyButton = null;
p9.add(applyButton = new JButton(Bundle.getMessage("ButtonApply")));
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
applyOptions(e);
}
});
applyButton.setToolTipText(Bundle.getMessage("ApplyButtonHint"));
optionsPane.add(p9);
}
if (initializeLayoutEditorCombo()) {
useConnectivityCheckBox.setVisible(true);
layoutEditorBox.setVisible(true);
} else {
useConnectivityCheckBox.setVisible(false);
layoutEditorBox.setVisible(false);
}
useConnectivityCheckBox.setSelected(dispatcher.getUseConnectivity());
signalTypeBox.setSelectedIndex(dispatcher.getSignalType());
trainsFromRoster.setSelected(dispatcher.getTrainsFromRoster());
trainsFromTrains.setSelected(dispatcher.getTrainsFromTrains());
trainsFromUser.setSelected(dispatcher.getTrainsFromUser());
detectionCheckBox.setSelected(dispatcher.getHasOccupancyDetection());
autoAllocateCheckBox.setSelected(dispatcher.getAutoAllocate());
autoTurnoutsCheckBox.setSelected(dispatcher.getAutoTurnouts());
trustKnownTurnoutsCheckBox.setSelected(dispatcher.getTrustKnownTurnouts());
shortNameCheckBox.setSelected(dispatcher.getShortActiveTrainNames());
nameInBlockCheckBox.setSelected(dispatcher.getShortNameInBlock());
rosterInBlockCheckBox.setSelected(dispatcher.getRosterEntryInBlock());
extraColorForAllocatedCheckBox.setSelected(dispatcher.getExtraColorForAllocated());
nameInAllocatedBlockCheckBox.setSelected(dispatcher.getNameInAllocatedBlock());
supportVSDecoderCheckBox.setSelected(dispatcher.getSupportVSDecoder());
scaleMeters.setSelected(dispatcher.getUseScaleMeters());
scaleFeet.setSelected(!dispatcher.getUseScaleMeters());
minThrottleIntervalTextField.setValue(dispatcher.getMinThrottleInterval());
fullRampTimeTextField.setValue(dispatcher.getFullRampTime());
if (dispatcher.getLayoutEditor() != null) {
openDispatcherWithPanel.setSelected(dispatcher.getLayoutEditor().getOpenDispatcherOnLoad());
}
optionsFrame.pack();
optionsFrame.setVisible(true);
}
use of java.awt.FlowLayout in project JMRI by JMRI.
the class CircuitBuilder method makeDoneButtonPanel.
private JPanel makeDoneButtonPanel(boolean add) {
JPanel buttonPanel = new JPanel();
JPanel panel0 = new JPanel();
panel0.setLayout(new FlowLayout());
JButton doneButton;
if (add) {
doneButton = new JButton(Bundle.getMessage("ButtonAddCircuit"));
doneButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
if (doAddAction()) {
_dialog.dispose();
}
}
});
} else {
doneButton = new JButton(Bundle.getMessage("ButtonOpenCircuit"));
doneButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
if (doOpenAction()) {
_dialog.dispose();
}
}
});
}
panel0.add(doneButton);
JButton cancelButton = new JButton(Bundle.getMessage("ButtonCancel"));
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
_sysNameBox.setText("");
_currentBlock = null;
_dialog.dispose();
}
});
panel0.add(cancelButton);
buttonPanel.add(panel0);
return buttonPanel;
}
Aggregations