use of javax.swing.ButtonGroup in project JMRI by JMRI.
the class MultiSensorItemPanel method makeMultiSensorPanel.
private void makeMultiSensorPanel() {
_multiSensorPanel = new JPanel();
_multiSensorPanel.setLayout(new BoxLayout(_multiSensorPanel, BoxLayout.Y_AXIS));
JPanel panel2 = new JPanel();
ButtonGroup group2 = new ButtonGroup();
JRadioButton button = new JRadioButton(Bundle.getMessage("LeftRight"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
_upDown = false;
}
});
group2.add(button);
panel2.add(button);
button.setSelected(true);
button = new JRadioButton(Bundle.getMessage("UpDown"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
_upDown = true;
}
});
group2.add(button);
panel2.add(button);
_multiSensorPanel.add(panel2);
_multiSensorPanel.repaint();
}
use of javax.swing.ButtonGroup in project JMRI by JMRI.
the class WarrantRoute method pickRoute.
/**
* Callback from RouteFinder - several routes found
*
* @param destNodes the destination blocks
* @param routeTree the routes
*/
protected void pickRoute(List<DefaultMutableTreeNode> destNodes, DefaultTreeModel routeTree) {
if (destNodes.size() == 1) {
showRoute(destNodes.get(0), routeTree);
selectedRoute(_orders);
return;
}
_pickRouteDialog = new JDialog(this, Bundle.getMessage("DialogTitle"), false);
_pickRouteDialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
clearTempWarrant();
}
});
_tempWarrant = null;
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout(5, 5));
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(new JLabel(Bundle.getMessage("NumberRoutes1", destNodes.size())));
panel.add(new JLabel(Bundle.getMessage("NumberRoutes2")));
mainPanel.add(panel, BorderLayout.NORTH);
ButtonGroup buttons = new ButtonGroup();
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
for (int i = 0; i < destNodes.size(); i++) {
JRadioButton button = new JRadioButton(Bundle.getMessage("RouteSize", i + 1, destNodes.get(i).getLevel() + 1));
button.setActionCommand("" + i);
button.addActionListener((ActionEvent e) -> {
clearTempWarrant();
});
buttons.add(button);
panel.add(button);
}
JScrollPane scrollPane = new JScrollPane(panel);
mainPanel.add(scrollPane, BorderLayout.CENTER);
JButton ok = new JButton(Bundle.getMessage("ButtonSelect"));
ok.addActionListener(new ActionListener() {
ButtonGroup buts;
JDialog dialog;
List<DefaultMutableTreeNode> dNodes;
DefaultTreeModel tree;
@Override
public void actionPerformed(ActionEvent e) {
if (buts.getSelection() != null) {
clearTempWarrant();
int i = Integer.parseInt(buttons.getSelection().getActionCommand());
showRoute(dNodes.get(i), tree);
selectedRoute(_orders);
dialog.dispose();
} else {
showWarning(Bundle.getMessage("SelectRoute"));
}
}
ActionListener init(ButtonGroup bg, JDialog d, List<DefaultMutableTreeNode> dn, DefaultTreeModel t) {
buts = bg;
dialog = d;
dNodes = dn;
tree = t;
return this;
}
}.init(buttons, _pickRouteDialog, destNodes, routeTree));
ok.setMaximumSize(ok.getPreferredSize());
JButton show = new JButton(Bundle.getMessage("ButtonReview"));
show.addActionListener(new ActionListener() {
ButtonGroup buts;
List<DefaultMutableTreeNode> destinationNodes;
DefaultTreeModel tree;
@Override
public void actionPerformed(ActionEvent e) {
if (buts.getSelection() != null) {
clearTempWarrant();
int i = Integer.parseInt(buttons.getSelection().getActionCommand());
showRoute(destinationNodes.get(i), tree);
showTempWarrant(_orders);
} else {
showWarning(Bundle.getMessage("SelectRoute"));
}
}
ActionListener init(ButtonGroup bg, List<DefaultMutableTreeNode> dn, DefaultTreeModel t) {
buts = bg;
destinationNodes = dn;
tree = t;
return this;
}
}.init(buttons, destNodes, routeTree));
show.setMaximumSize(show.getPreferredSize());
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
panel.add(show);
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
panel.add(ok);
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
mainPanel.add(panel, BorderLayout.SOUTH);
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
panel.add(makeRouteTablePanel());
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
panel.add(mainPanel);
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
_pickRouteDialog.getContentPane().add(panel);
_pickRouteDialog.setLocation(getLocation().x - 20, getLocation().y + 150);
_pickRouteDialog.pack();
_pickRouteDialog.setVisible(true);
}
use of javax.swing.ButtonGroup in project JMRI by JMRI.
the class WarrantPreferencesPanel method interpretationPanel.
private JPanel interpretationPanel() {
_interpretation = WarrantPreferences.getDefault().getInterpretation();
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
ButtonGroup group = new ButtonGroup();
makeButton(buttonPanel, group, "percentNormal", "ToolTipPercentNormal", SignalSpeedMap.PERCENT_NORMAL);
makeButton(buttonPanel, group, "percentThrottle", "ToolTipPercentThrottle", SignalSpeedMap.PERCENT_THROTTLE);
makeButton(buttonPanel, group, "speedMph", "ToolTipSpeedMph", SignalSpeedMap.SPEED_MPH);
makeButton(buttonPanel, group, "speedKmph", "ToolTipSpeedKmph", SignalSpeedMap.SPEED_KMPH);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
JPanel p = new JPanel();
JLabel label = new JLabel(Bundle.getMessage("LabelInterpretation"));
label.setToolTipText(Bundle.getMessage("ToolTipInterpretation"));
p.setToolTipText(Bundle.getMessage("ToolTipInterpretation"));
p.add(label);
panel.add(p);
panel.add(buttonPanel, Box.CENTER_ALIGNMENT);
return panel;
}
use of javax.swing.ButtonGroup in project JMRI by JMRI.
the class TrackDestinationEditFrame method initComponents.
public void initComponents(Track track) {
_track = track;
// property changes
// the following code sets the frame's initial state
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
// Set up the panels
// Layout the panel by rows
// row 1
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
p1.setMaximumSize(new Dimension(2000, 250));
// row 1a
JPanel pTrackName = new JPanel();
pTrackName.setLayout(new GridBagLayout());
pTrackName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Track")));
addItem(pTrackName, trackName, 0, 0);
// row 1b
JPanel pLocationName = new JPanel();
pLocationName.setLayout(new GridBagLayout());
pLocationName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Location")));
addItem(pLocationName, new JLabel(_track.getLocation().getName()), 0, 0);
p1.add(pTrackName);
p1.add(pLocationName);
// row 3
JPanel p3 = new JPanel();
p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
JScrollPane pane3 = new JScrollPane(p3);
pane3.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("DestinationTrack")));
pane3.setMaximumSize(new Dimension(2000, 400));
JPanel pRadioButtons = new JPanel();
pRadioButtons.setLayout(new FlowLayout());
pRadioButtons.add(destinationsAll);
pRadioButtons.add(destinationsInclude);
pRadioButtons.add(destinationsExclude);
p3.add(pRadioButtons);
// row 4 only for interchange / classification tracks
JPanel pFD = new JPanel();
pFD.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Options")));
pFD.add(onlyCarsWithFD);
pFD.setMaximumSize(new Dimension(2000, 200));
// row 5
panelDestinations.setLayout(new GridBagLayout());
paneDestinations.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Destinations")));
ButtonGroup bGroup = new ButtonGroup();
bGroup.add(destinationsAll);
bGroup.add(destinationsInclude);
bGroup.add(destinationsExclude);
// row 12
JPanel panelButtons = new JPanel();
panelButtons.setLayout(new GridBagLayout());
panelButtons.setBorder(BorderFactory.createTitledBorder(""));
panelButtons.setMaximumSize(new Dimension(2000, 200));
// row 13
addItem(panelButtons, checkDestinationsButton, 0, 0);
addItem(panelButtons, saveTrackButton, 1, 0);
getContentPane().add(p1);
getContentPane().add(pane3);
getContentPane().add(pFD);
getContentPane().add(paneDestinations);
getContentPane().add(panelButtons);
// setup buttons
addButtonAction(checkDestinationsButton);
addButtonAction(saveTrackButton);
addRadioButtonAction(destinationsAll);
addRadioButtonAction(destinationsInclude);
addRadioButtonAction(destinationsExclude);
// load fields and enable buttons
if (_track != null) {
_track.addPropertyChangeListener(this);
trackName.setText(_track.getName());
onlyCarsWithFD.setSelected(_track.isOnlyCarsWithFinalDestinationEnabled());
pFD.setVisible(_track.getTrackType().equals(Track.INTERCHANGE));
enableButtons(true);
} else {
enableButtons(false);
}
updateDestinations();
locationManager.addPropertyChangeListener(this);
// build menu
// JMenuBar menuBar = new JMenuBar();
// _toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
// menuBar.add(_toolMenu);
// setJMenuBar(menuBar);
initMinimumSize(new Dimension(Control.panelWidth400, Control.panelHeight500));
}
use of javax.swing.ButtonGroup in project JMRI by JMRI.
the class TrackLoadEditFrame method initComponents.
public void initComponents(Location location, Track track) {
_location = location;
_track = track;
// property changes
_location.addPropertyChangeListener(this);
// listen for car load name and type changes
CarLoads.instance().addPropertyChangeListener(this);
CarTypes.instance().addPropertyChangeListener(this);
// the following code sets the frame's initial state
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
// Set up the panels
// Layout the panel by rows
// row 1
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
p1.setMaximumSize(new Dimension(2000, 250));
// row 1a
JPanel pTrackName = new JPanel();
pTrackName.setLayout(new GridBagLayout());
pTrackName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Track")));
addItem(pTrackName, trackName, 0, 0);
// row 1b
JPanel pLocationName = new JPanel();
pLocationName.setLayout(new GridBagLayout());
pLocationName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Location")));
addItem(pLocationName, new JLabel(_location.getName()), 0, 0);
p1.add(pTrackName);
p1.add(pLocationName);
// row 3
JPanel p3 = new JPanel();
p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
JScrollPane pane3 = new JScrollPane(p3);
pane3.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LoadsTrack")));
pane3.setMaximumSize(new Dimension(2000, 400));
JPanel pLoadRadioButtons = new JPanel();
pLoadRadioButtons.setLayout(new FlowLayout());
pLoadRadioButtons.add(loadNameAll);
pLoadRadioButtons.add(loadNameInclude);
pLoadRadioButtons.add(loadNameExclude);
pLoadRadioButtons.add(loadAndTypeCheckBox);
pLoadControls.setLayout(new FlowLayout());
pLoadControls.add(comboBoxTypes);
pLoadControls.add(comboBoxLoads);
pLoadControls.add(addLoadButton);
pLoadControls.add(deleteLoadButton);
pLoadControls.add(deleteAllLoadsButton);
pLoadControls.setVisible(false);
p3.add(pLoadRadioButtons);
p3.add(pLoadControls);
// row 4
panelLoads.setLayout(new GridBagLayout());
paneLoads.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Loads")));
ButtonGroup loadGroup = new ButtonGroup();
loadGroup.add(loadNameAll);
loadGroup.add(loadNameInclude);
loadGroup.add(loadNameExclude);
// row 6
JPanel p6 = new JPanel();
p6.setLayout(new BoxLayout(p6, BoxLayout.Y_AXIS));
paneShipLoadControls = new JScrollPane(p6);
paneShipLoadControls.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ShipLoadsTrack")));
paneShipLoadControls.setMaximumSize(new Dimension(2000, 400));
JPanel pShipLoadRadioButtons = new JPanel();
pShipLoadRadioButtons.setLayout(new FlowLayout());
pShipLoadRadioButtons.add(shipLoadNameAll);
pShipLoadRadioButtons.add(shipLoadNameInclude);
pShipLoadRadioButtons.add(shipLoadNameExclude);
pShipLoadRadioButtons.add(shipLoadAndTypeCheckBox);
pShipLoadControls.setLayout(new FlowLayout());
pShipLoadControls.add(comboBoxShipTypes);
pShipLoadControls.add(comboBoxShipLoads);
pShipLoadControls.add(addShipLoadButton);
pShipLoadControls.add(deleteShipLoadButton);
pShipLoadControls.add(deleteAllShipLoadsButton);
pShipLoadControls.setVisible(false);
p6.add(pShipLoadRadioButtons);
p6.add(pShipLoadControls);
// row 7
panelShipLoads.setLayout(new GridBagLayout());
paneShipLoads.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Loads")));
ButtonGroup shipLoadGroup = new ButtonGroup();
shipLoadGroup.add(shipLoadNameAll);
shipLoadGroup.add(shipLoadNameInclude);
shipLoadGroup.add(shipLoadNameExclude);
JPanel pOptions = new JPanel();
pOptions.setLayout(new GridBagLayout());
pOptions.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Options")));
pOptions.setMaximumSize(new Dimension(2000, 400));
addItem(pOptions, holdCars, 0, 0);
holdCars.setText(Bundle.getMessage("HoldCarsWithCustomLoads"));
holdCars.setToolTipText(Bundle.getMessage("HoldCarsWithCustomLoadsTip"));
// row 12
JPanel panelButtons = new JPanel();
panelButtons.setLayout(new GridBagLayout());
panelButtons.setBorder(BorderFactory.createTitledBorder(""));
panelButtons.setMaximumSize(new Dimension(2000, 200));
// row 13
addItem(panelButtons, saveTrackButton, 0, 0);
getContentPane().add(p1);
getContentPane().add(pane3);
getContentPane().add(paneLoads);
getContentPane().add(paneShipLoadControls);
getContentPane().add(paneShipLoads);
getContentPane().add(pOptions);
getContentPane().add(panelButtons);
// setup buttons
addButtonAction(saveTrackButton);
addButtonAction(deleteLoadButton);
addButtonAction(deleteAllLoadsButton);
addButtonAction(addLoadButton);
addButtonAction(deleteShipLoadButton);
addButtonAction(deleteAllShipLoadsButton);
addButtonAction(addShipLoadButton);
addRadioButtonAction(loadNameAll);
addRadioButtonAction(loadNameInclude);
addRadioButtonAction(loadNameExclude);
addRadioButtonAction(shipLoadNameAll);
addRadioButtonAction(shipLoadNameInclude);
addRadioButtonAction(shipLoadNameExclude);
addComboBoxAction(comboBoxTypes);
addComboBoxAction(comboBoxShipTypes);
paneShipLoadControls.setVisible(false);
paneShipLoads.setVisible(false);
pOptions.setVisible(false);
// load fields and enable buttons
if (_track != null) {
_track.addPropertyChangeListener(this);
trackName.setText(_track.getName());
// only show ship loads for staging tracks
paneShipLoadControls.setVisible(_track.getTrackType().equals(Track.STAGING));
paneShipLoads.setVisible(_track.getTrackType().equals(Track.STAGING));
pOptions.setVisible(_track.getTrackType().equals(Track.SPUR));
holdCars.setSelected(_track.isHoldCarsWithCustomLoadsEnabled());
updateButtons(true);
} else {
updateButtons(false);
}
// build menu
// JMenuBar menuBar = new JMenuBar();
// _toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
// menuBar.add(_toolMenu);
// setJMenuBar(menuBar);
// load
updateTypeComboBoxes();
updateLoadComboBoxes();
updateLoadNames();
updateShipLoadNames();
loadAndTypeCheckBox.setSelected(loadAndType);
shipLoadAndTypeCheckBox.setSelected(shipLoadAndType);
// add help menu to window
// NOI18N
addHelpMenu("package.jmri.jmrit.operations.Operations_LoadOptions", true);
initMinimumSize(new Dimension(Control.panelWidth600, Control.panelHeight400));
}
Aggregations