use of javax.swing.JMenuBar in project JMRI by JMRI.
the class TrackEditFrame method initComponents.
public void initComponents(Location location, Track track) {
_location = location;
_track = track;
// tool tips
autoDropCheckBox.setToolTipText(Bundle.getMessage("TipAutoTrack"));
autoPickupCheckBox.setToolTipText(Bundle.getMessage("TipAutoTrack"));
trackLengthTextField.setToolTipText(MessageFormat.format(Bundle.getMessage("TipTrackLength"), new Object[] { Setup.getLengthUnit().toLowerCase() }));
// property changes
_location.addPropertyChangeListener(this);
// listen for car road name and type changes
CarRoads.instance().addPropertyChangeListener(this);
CarLoads.instance().addPropertyChangeListener(this);
CarTypes.instance().addPropertyChangeListener(this);
trainManager.addPropertyChangeListener(this);
routeManager.addPropertyChangeListener(this);
// the following code sets the frame's initial state
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
// place all panels in a scroll pane.
JPanel panels = new JPanel();
panels.setLayout(new BoxLayout(panels, BoxLayout.Y_AXIS));
JScrollPane pane = new JScrollPane(panels);
// Set up the panels
// Layout the panel by rows
// row 1
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
JScrollPane p1Pane = new JScrollPane(p1);
p1Pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
p1Pane.setMinimumSize(new Dimension(300, 3 * trackNameTextField.getPreferredSize().height));
p1Pane.setBorder(BorderFactory.createTitledBorder(""));
// row 1a
JPanel pName = new JPanel();
pName.setLayout(new GridBagLayout());
pName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Name")));
addItem(pName, trackNameTextField, 0, 0);
// row 1b
JPanel pLength = new JPanel();
pLength.setLayout(new GridBagLayout());
pLength.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Length")));
pLength.setMinimumSize(new Dimension(60, 1));
addItem(pLength, trackLengthTextField, 0, 0);
// row 1c
panelTrainDir.setLayout(new GridBagLayout());
panelTrainDir.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TrainTrack")));
panelTrainDir.setPreferredSize(new Dimension(200, 10));
addItem(panelTrainDir, northCheckBox, 1, 1);
addItem(panelTrainDir, southCheckBox, 2, 1);
addItem(panelTrainDir, eastCheckBox, 3, 1);
addItem(panelTrainDir, westCheckBox, 4, 1);
p1.add(pName);
p1.add(pLength);
p1.add(panelTrainDir);
// row 4
panelCheckBoxes.setLayout(new GridBagLayout());
// status panel for roads and loads
JPanel panelRoadAndLoadStatus = new JPanel();
panelRoadAndLoadStatus.setLayout(new BoxLayout(panelRoadAndLoadStatus, BoxLayout.X_AXIS));
JPanel pRoadOption = new JPanel();
pRoadOption.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("RoadOption")));
pRoadOption.add(roadOption);
JPanel pLoadOption = new JPanel();
pLoadOption.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LoadOption")));
pLoadOption.add(loadOption);
pShipLoadOption.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ShipLoadOption")));
pShipLoadOption.add(shipLoadOption);
pDestinationOption.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Destinations")));
pDestinationOption.add(destinationOption);
panelRoadAndLoadStatus.add(pRoadOption);
panelRoadAndLoadStatus.add(pLoadOption);
panelRoadAndLoadStatus.add(pShipLoadOption);
panelRoadAndLoadStatus.add(pDestinationOption);
// only staging uses the ship load option
pShipLoadOption.setVisible(false);
// only classification/interchange tracks use the destination option
pDestinationOption.setVisible(false);
// row 10
// order panel
panelOrder.setLayout(new GridBagLayout());
panelOrder.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("PickupOrder")));
panelOrder.add(orderNormal);
panelOrder.add(orderFIFO);
panelOrder.add(orderLIFO);
ButtonGroup orderGroup = new ButtonGroup();
orderGroup.add(orderNormal);
orderGroup.add(orderFIFO);
orderGroup.add(orderLIFO);
// drop panel
dropPanel.setLayout(new GridBagLayout());
dropPanel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TrainsOrRoutesDrops")));
// pickup panel
pickupPanel.setLayout(new GridBagLayout());
pickupPanel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TrainsOrRoutesPickups")));
// row 11
JPanel panelComment = new JPanel();
panelComment.setLayout(new GridBagLayout());
panelComment.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Comment")));
addItem(panelComment, commentScroller, 0, 0);
// adjust text area width based on window size
adjustTextAreaColumnWidth(commentScroller, commentTextArea);
// reader row
JPanel readerPanel = new JPanel();
readerPanel.setLayout(new GridBagLayout());
readerPanel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("idReader")));
addItem(readerPanel, readerSelector, 0, 0);
readerPanel.setVisible(Setup.isRfidEnabled());
// row 12
JPanel panelButtons = new JPanel();
panelButtons.setLayout(new GridBagLayout());
// row 13
addItem(panelButtons, deleteTrackButton, 0, 0);
addItem(panelButtons, addTrackButton, 1, 0);
addItem(panelButtons, saveTrackButton, 2, 0);
paneCheckBoxes.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TypesTrack")));
panels.add(p1Pane);
panels.add(paneCheckBoxes);
panels.add(panelRoadAndLoadStatus);
panels.add(panelOrder);
panels.add(dropPanel);
panels.add(pickupPanel);
// add optional panels
panels.add(panelOpt3);
panels.add(panelOpt4);
panels.add(panelComment);
panels.add(readerPanel);
panels.add(panelButtons);
getContentPane().add(pane);
// setup buttons
addButtonAction(setButton);
addButtonAction(clearButton);
addButtonAction(deleteTrackButton);
addButtonAction(addTrackButton);
addButtonAction(saveTrackButton);
addButtonAction(deleteDropButton);
addButtonAction(addDropButton);
addButtonAction(deletePickupButton);
addButtonAction(addPickupButton);
addRadioButtonAction(orderNormal);
addRadioButtonAction(orderFIFO);
addRadioButtonAction(orderLIFO);
addRadioButtonAction(anyDrops);
addRadioButtonAction(trainDrop);
addRadioButtonAction(routeDrop);
addRadioButtonAction(excludeTrainDrop);
addRadioButtonAction(excludeRouteDrop);
addRadioButtonAction(anyPickups);
addRadioButtonAction(trainPickup);
addRadioButtonAction(routePickup);
addRadioButtonAction(excludeTrainPickup);
addRadioButtonAction(excludeRoutePickup);
// addComboBoxAction(comboBoxTypes);
addCheckBoxAction(autoDropCheckBox);
addCheckBoxAction(autoPickupCheckBox);
if (Setup.isRfidEnabled()) {
// setup the Reader dropdown.
// add an empty entry.
readerSelector.addItem(null);
for (jmri.NamedBean r : jmri.InstanceManager.getDefault(jmri.ReporterManager.class).getNamedBeanList()) {
readerSelector.addItem((Reporter) r);
}
}
// load fields and enable buttons
if (_track != null) {
_track.addPropertyChangeListener(this);
trackNameTextField.setText(_track.getName());
commentTextArea.setText(_track.getComment());
trackLengthTextField.setText(Integer.toString(_track.getLength()));
enableButtons(true);
_trackName = _track.getName();
if (Setup.isRfidEnabled()) {
readerSelector.setSelectedItem(_track.getReporter());
}
} else {
enableButtons(false);
}
// build menu
JMenuBar menuBar = new JMenuBar();
_toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
_toolMenu.add(new TrackLoadEditAction(this));
_toolMenu.add(new TrackRoadEditAction(this));
_toolMenu.add(new TrackEditCommentsAction(this));
_toolMenu.add(new PoolTrackAction(this));
menuBar.add(_toolMenu);
setJMenuBar(menuBar);
// load
updateCheckboxes();
// updateTypeComboBoxes();
updateTrainDir();
updateCarOrder();
updateDropOptions();
updatePickupOptions();
updateRoadOption();
updateLoadOption();
updateDestinationOption();
setMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight600));
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class VSDecoderFrame method buildMenu.
private void buildMenu() {
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
fileMenu.add(new LoadVSDFileAction(Bundle.getMessage("VSDecoderFileMenuLoadVSDFile")));
fileMenu.add(new StoreXmlVSDecoderAction(Bundle.getMessage("VSDecoderFileMenuSaveProfile")));
fileMenu.add(new LoadXmlVSDecoderAction(Bundle.getMessage("VSDecoderFileMenuLoadProfile")));
fileMenu.addSeparator();
fileMenu.add(new VSDPreferencesAction(Bundle.getMessage("VSDecoderFileMenuPreferences")));
// disable XML store
fileMenu.getItem(1).setEnabled(false);
// disable XML load
fileMenu.getItem(2).setEnabled(false);
menuList = new ArrayList<JMenu>(2);
menuList.add(fileMenu);
this.setJMenuBar(new JMenuBar());
this.getJMenuBar().add(fileMenu);
this.addHelpMenu("package.jmri.jmrit.vsdecoder.VSDecoderFrame", true);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class UserInterface method buildMenu.
protected void buildMenu() {
this.setJMenuBar(new JMenuBar());
JMenu menu = new JMenu(rb.getString("MenuMenu"));
serverOnOff = new JMenuItem(rb.getString("MenuMenuStop"));
serverOnOff.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent event) {
if (isListen) {
// Stop server
disableServer();
serverOnOff.setText(rb.getString("MenuMenuStart"));
portLabel.setText(rb.getString("LabelNone"));
manualPortLabel.setText(null);
} else {
// Restart server
serverOnOff.setText(rb.getString("MenuMenuStop"));
isListen = true;
createServerThread();
}
}
});
menu.add(serverOnOff);
menu.add(new ControllerFilterAction());
Action prefsAction = new apps.gui3.TabbedPreferencesAction(ResourceBundle.getBundle("apps.AppsBundle").getString("MenuItemPreferences"), "WITHROTTLE");
menu.add(prefsAction);
this.getJMenuBar().add(menu);
// add help menu
addHelpMenu("package.jmri.jmrit.withrottle.UserInterface", true);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class StackMonFrame method addNotify.
@Override
public void addNotify() {
super.addNotify();
// resize frame to account for menubar
JMenuBar jMenuBar = getJMenuBar();
if (jMenuBar != null) {
int jMenuBarHeight = jMenuBar.getPreferredSize().height;
Dimension dimension = getSize();
dimension.height += jMenuBarHeight;
setSize(dimension);
}
}
use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.
the class MisplacedBorder method run.
@Override
public void run() {
final JMenuBar menubar = new JMenuBar();
menubar.add(new JMenu(""));
menubar.add(new JMenu(""));
final JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setJMenuBar(menubar);
frame.setSize(W / 3, H / 3);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
// draw menu bar using standard order.
final BufferedImage bi1 = step1(menubar);
// draw menu border on top of the menu bar, nothing should be changed.
final BufferedImage bi2 = step2(menubar);
frame.dispose();
for (int x = 0; x < W; ++x) {
for (int y = 0; y < H; ++y) {
if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
try {
ImageIO.write(bi1, "png", new File("image1.png"));
ImageIO.write(bi2, "png", new File("image2.png"));
} catch (IOException e) {
e.printStackTrace();
}
throw new RuntimeException("Failed: wrong color");
}
}
}
}
Aggregations