use of javax.swing.JMenuBar in project JMRI by JMRI.
the class PanelEditor method init.
@Override
protected void init(String name) {
Runnable r = new Runnable() {
@Override
public void run() {
try {
// Build resource catalog and load CatalogTree.xml now
jmri.jmrit.catalog.CatalogPanel catalog = new jmri.jmrit.catalog.CatalogPanel();
catalog.createNewBranch("IFJAR", "Program Directory", "resources");
} catch (Exception ex) {
log.error("Error in trying to setup preferences " + ex.toString());
}
}
};
Thread thr = new Thread(r);
thr.start();
java.awt.Container contentPane = this.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
// common items
JPanel common = new JPanel();
common.setLayout(new FlowLayout());
common.add(new JLabel(" x:"));
common.add(nextX);
common.add(new JLabel(" y:"));
common.add(nextY);
contentPane.add(common);
setAllEditable(true);
setShowHidden(true);
super.setTargetPanel(null, makeFrame(name));
super.setTargetPanelSize(400, 300);
super.setDefaultToolTip(new ToolTip(null, 0, 0, new Font("SansSerif", Font.PLAIN, 12), Color.black, new Color(215, 225, 255), Color.black));
// set scrollbar initial state
setScroll(SCROLL_BOTH);
// add menu - not using PanelMenu, because it now
// has other stuff in it?
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
menuBar.add(fileMenu);
fileMenu.add(new jmri.jmrit.display.NewPanelAction(Bundle.getMessage("MenuItemNew")));
fileMenu.add(new jmri.configurexml.StoreXmlUserAction(Bundle.getMessage("MenuItemStore")));
JMenuItem storeIndexItem = new JMenuItem(Bundle.getMessage("MIStoreImageIndex"));
fileMenu.add(storeIndexItem);
storeIndexItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
jmri.jmrit.catalog.ImageIndexEditor.storeImageIndex();
}
});
JMenuItem editItem = new JMenuItem(Bundle.getMessage("editIndexMenu"));
editItem.addActionListener(new ActionListener() {
PanelEditor panelEd;
@Override
public void actionPerformed(ActionEvent e) {
ImageIndexEditor ii = ImageIndexEditor.instance(panelEd);
ii.pack();
ii.setVisible(true);
}
ActionListener init(PanelEditor pe) {
panelEd = pe;
return this;
}
}.init(this));
fileMenu.add(editItem);
editItem = new JMenuItem(Bundle.getMessage("CPEView"));
fileMenu.add(editItem);
editItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
changeView("jmri.jmrit.display.controlPanelEditor.ControlPanelEditor");
}
});
fileMenu.addSeparator();
JMenuItem deleteItem = new JMenuItem(Bundle.getMessage("DeletePanel"));
fileMenu.add(deleteItem);
deleteItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (deletePanel()) {
dispose(true);
}
}
});
setJMenuBar(menuBar);
addHelpMenu("package.jmri.jmrit.display.PanelEditor", true);
// allow naming the panel
{
JPanel namep = new JPanel();
namep.setLayout(new FlowLayout());
JButton b = new JButton(Bundle.getMessage("ButtonSetName"));
b.addActionListener(new ActionListener() {
PanelEditor editor;
@Override
public void actionPerformed(ActionEvent e) {
// prompt for name
String newName = JOptionPane.showInputDialog(null, Bundle.getMessage("PromptNewName"));
if (newName == null) {
// cancelled
return;
}
if (jmri.jmrit.display.PanelMenu.instance().isPanelNameUsed(newName)) {
JOptionPane.showMessageDialog(null, Bundle.getMessage("CanNotRename"), Bundle.getMessage("PanelExist"), JOptionPane.ERROR_MESSAGE);
return;
}
if (getTargetPanel().getTopLevelAncestor() != null) {
((JFrame) getTargetPanel().getTopLevelAncestor()).setTitle(newName);
}
editor.setTitle();
jmri.jmrit.display.PanelMenu.instance().renameEditorPanel(editor);
}
ActionListener init(PanelEditor e) {
editor = e;
return this;
}
}.init(this));
namep.add(b);
this.getContentPane().add(namep);
}
// add a text label
{
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(labelAdd);
labelAdd.setEnabled(false);
labelAdd.setToolTipText(Bundle.getMessage("ToolTipWillActivate"));
panel.add(nextLabel);
labelAdd.addActionListener(new ActionListener() {
PanelEditor editor;
@Override
public void actionPerformed(ActionEvent a) {
editor.addLabel(nextLabel.getText());
}
ActionListener init(PanelEditor e) {
editor = e;
return this;
}
}.init(this));
nextLabel.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent a) {
if (nextLabel.getText().equals("")) {
labelAdd.setEnabled(false);
labelAdd.setToolTipText(Bundle.getMessage("ToolTipWillActivate"));
} else {
labelAdd.setEnabled(true);
labelAdd.setToolTipText(null);
}
}
});
this.getContentPane().add(panel);
}
// Selection of the type of entity for the icon to represent is done from a combobox
_addIconBox = new JComboBox<ComboBoxItem>();
_addIconBox.setMinimumSize(new Dimension(75, 75));
_addIconBox.setMaximumSize(new Dimension(200, 200));
_addIconBox.addItem(new ComboBoxItem("RightTurnout"));
_addIconBox.addItem(new ComboBoxItem("LeftTurnout"));
_addIconBox.addItem(new ComboBoxItem("SlipTOEditor"));
// NOI18N
_addIconBox.addItem(new ComboBoxItem("Sensor"));
_addIconBox.addItem(new ComboBoxItem("SignalHead"));
_addIconBox.addItem(new ComboBoxItem("SignalMast"));
_addIconBox.addItem(new ComboBoxItem("Memory"));
_addIconBox.addItem(new ComboBoxItem("BlockLabel"));
_addIconBox.addItem(new ComboBoxItem("Reporter"));
_addIconBox.addItem(new ComboBoxItem("Light"));
_addIconBox.addItem(new ComboBoxItem("Background"));
_addIconBox.addItem(new ComboBoxItem("MultiSensor"));
_addIconBox.addItem(new ComboBoxItem("RPSreporter"));
_addIconBox.addItem(new ComboBoxItem("FastClock"));
_addIconBox.addItem(new ComboBoxItem("Icon"));
_addIconBox.setSelectedIndex(-1);
// must be AFTER no selection is set
_addIconBox.addItemListener(this);
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout());
p2.add(new JLabel(Bundle.getMessage("selectTypeIcon")));
p1.add(p2);
p1.add(_addIconBox);
contentPane.add(p1);
// edit, position, control controls
{
// edit mode item
contentPane.add(editableBox);
editableBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setAllEditable(editableBox.isSelected());
hiddenCheckBoxListener();
}
});
editableBox.setSelected(isEditable());
// positionable item
contentPane.add(positionableBox);
positionableBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setAllPositionable(positionableBox.isSelected());
}
});
positionableBox.setSelected(allPositionable());
// controlable item
contentPane.add(controllingBox);
controllingBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setAllControlling(controllingBox.isSelected());
}
});
controllingBox.setSelected(allControlling());
// hidden item
contentPane.add(hiddenBox);
hiddenCheckBoxListener();
hiddenBox.setSelected(showHidden());
/*
contentPane.add(showCoordinatesBox);
showCoordinatesBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setShowCoordinates(showCoordinatesBox.isSelected());
}
});
showCoordinatesBox.setSelected(showCoordinates());
*/
contentPane.add(showTooltipBox);
showTooltipBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setAllShowTooltip(showTooltipBox.isSelected());
}
});
showTooltipBox.setSelected(showTooltip());
contentPane.add(menuBox);
menuBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setPanelMenuVisible(menuBox.isSelected());
}
});
menuBox.setSelected(true);
// Show/Hide Scroll Bars
JPanel scrollPanel = new JPanel();
scrollPanel.setLayout(new FlowLayout());
scrollableLabel.setLabelFor(scrollableComboBox);
scrollPanel.add(scrollableLabel);
scrollPanel.add(scrollableComboBox);
contentPane.add(scrollPanel);
scrollableComboBox.addItem(Bundle.getMessage("ScrollNone"));
scrollableComboBox.addItem(Bundle.getMessage("ScrollBoth"));
scrollableComboBox.addItem(Bundle.getMessage("ScrollHorizontal"));
scrollableComboBox.addItem(Bundle.getMessage("ScrollVertical"));
scrollableComboBox.setSelectedIndex(SCROLL_BOTH);
scrollableComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setScroll(scrollableComboBox.getSelectedIndex());
}
});
}
// register the resulting panel for later configuration
ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
if (cm != null) {
cm.registerUser(this);
}
// when this window closes, set contents of target uneditable
addWindowListener(new java.awt.event.WindowAdapter() {
HashMap<String, JFrameItem> iconAdderFrames;
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
Iterator<JFrameItem> iter = iconAdderFrames.values().iterator();
while (iter.hasNext()) {
JFrameItem frame = iter.next();
frame.dispose();
}
}
WindowAdapter init(HashMap<String, JFrameItem> f) {
iconAdderFrames = f;
return this;
}
}.init(_iconEditorFrame));
// and don't destroy the window
setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
// move this editor panel off the panel's position
getTargetFrame().setLocationRelativeTo(this);
getTargetFrame().pack();
getTargetFrame().setVisible(true);
log.debug("PanelEditor ctor done.");
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class LocationsByCarLoadFrame method initComponents.
@Override
public void initComponents() {
// load managers
locationManager = LocationManager.instance();
// general GUI config
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
// Set up the panels
JPanel pCarType = new JPanel();
pCarType.setLayout(new GridBagLayout());
pCarType.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Type")));
addItem(pCarType, typeComboBox, 0, 0);
JPanel pLoad = new JPanel();
pLoad.setLayout(new GridBagLayout());
pLoad.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Load")));
addItem(pLoad, loadComboBox, 0, 0);
addItem(pLoad, loadAndTypeCheckBox, 1, 0);
pLocations = new JPanel();
pLocations.setLayout(new GridBagLayout());
JScrollPane locationPane = new JScrollPane(pLocations);
locationPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
locationPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Locations")));
updateLoadComboBox();
JPanel pButtons = new JPanel();
pButtons.setLayout(new GridBagLayout());
pButtons.setBorder(BorderFactory.createTitledBorder(""));
addItem(pButtons, clearButton, 0, 0);
addItem(pButtons, setButton, 1, 0);
addItem(pButtons, saveButton, 2, 0);
getContentPane().add(pCarType);
getContentPane().add(pLoad);
getContentPane().add(locationPane);
getContentPane().add(pButtons);
// setup combo box
addComboBoxAction(typeComboBox);
addComboBoxAction(loadComboBox);
// setup buttons
addButtonAction(setButton);
addButtonAction(clearButton);
addButtonAction(saveButton);
// setup checkbox
addCheckBoxAction(loadAndTypeCheckBox);
locationManager.addPropertyChangeListener(this);
CarTypes.instance().addPropertyChangeListener(this);
CarLoads.instance().addPropertyChangeListener(this);
// build menu
JMenuBar menuBar = new JMenuBar();
JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
toolMenu.add(new PrintLocationsByCarTypesAction(Bundle.getMessage("MenuItemPrintByType"), new Frame(), false, this));
toolMenu.add(new PrintLocationsByCarTypesAction(Bundle.getMessage("MenuItemPreviewByType"), new Frame(), true, this));
menuBar.add(toolMenu);
setJMenuBar(menuBar);
// NOI18N
addHelpMenu("package.jmri.jmrit.operations.Operations_ModifyLocationsByCarType", true);
// we need to resize this frame
setPreferredSize(null);
pack();
setMinimumSize(new Dimension(Control.panelWidth300, Control.panelHeight250));
// make a bit wider to eliminate scroll bar
setSize(getWidth() + 25, getHeight());
if (_location != null) {
setTitle(Bundle.getMessage("TitleModifyLocationLoad"));
} else {
setTitle(Bundle.getMessage("TitleModifyLocationsLoad"));
}
setVisible(true);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class CarLoadEditFrame method initComponents.
public void initComponents(String type, String select) {
getContentPane().removeAll();
setTitle(MessageFormat.format(Bundle.getMessage("TitleCarEditLoad"), new Object[] { type }));
// track which combo box is being edited
_type = type;
loadComboboxes();
loadComboBox.setSelectedItem(select);
updateLoadType();
updatePriority();
// general GUI config
quanity.setVisible(showQuanity);
// load panel
JPanel pLoad = new JPanel();
pLoad.setLayout(new GridBagLayout());
pLoad.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Load")));
// row 2
addItem(pLoad, addTextBox, 2, 2);
addItem(pLoad, addButton, 3, 2);
// row 3
addItem(pLoad, quanity, 1, 3);
addItem(pLoad, loadComboBox, 2, 3);
addItem(pLoad, deleteButton, 3, 3);
// row 4
addItem(pLoad, replaceButton, 3, 4);
// row 6
JPanel pLoadType = new JPanel();
pLoadType.setLayout(new BoxLayout(pLoadType, BoxLayout.Y_AXIS));
pLoadType.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutLoadType")));
addItem(pLoadType, loadTypeComboBox, 0, 0);
// row 8
JPanel pPriority = new JPanel();
pPriority.setLayout(new BoxLayout(pPriority, BoxLayout.Y_AXIS));
pPriority.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutPriority")));
addItem(pPriority, priorityComboBox, 0, 0);
// row 10
// optional panel
JPanel pOptionalPickup = new JPanel();
// pOptionalPickup.setLayout(new BoxLayout(pOptionalPickup, BoxLayout.Y_AXIS));
pOptionalPickup.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutOptionalPickup")));
addItem(pOptionalPickup, pickupCommentTextField, 0, 0);
// row 12
JPanel pOptionalDrop = new JPanel();
// pOptionalDrop.setLayout(new BoxLayout(pOptionalDrop, BoxLayout.Y_AXIS));
pOptionalDrop.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutOptionalDrop")));
addItem(pOptionalDrop, dropCommentTextField, 0, 0);
// row 14
JPanel pControl = new JPanel();
pControl.setLayout(new BoxLayout(pControl, BoxLayout.Y_AXIS));
addItem(pControl, saveButton, 0, 0);
// add panels
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
getContentPane().add(pLoad);
getContentPane().add(pLoadType);
getContentPane().add(pPriority);
getContentPane().add(pOptionalPickup);
getContentPane().add(pOptionalDrop);
getContentPane().add(pControl);
addButtonAction(addButton);
addButtonAction(deleteButton);
addButtonAction(replaceButton);
addButtonAction(saveButton);
addComboBoxAction(loadComboBox);
updateCarCommentFields();
// build menu
JMenuBar menuBar = new JMenuBar();
JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
toolMenu.add(new CarLoadAttributeAction(Bundle.getMessage("CarQuantity"), this));
toolMenu.add(new PrintCarLoadsAction(Bundle.getMessage("MenuItemPreview"), true, this));
toolMenu.add(new PrintCarLoadsAction(Bundle.getMessage("MenuItemPrint"), false, this));
menuBar.add(toolMenu);
setJMenuBar(menuBar);
// add help menu to window
// NOI18N
addHelpMenu("package.jmri.jmrit.operations.Operations_EditCarLoads", true);
initMinimumSize(new Dimension(Control.panelWidth300, Control.panelHeight500));
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class OperationsSetupFrame method initComponents.
@Override
public void initComponents() {
super.initComponents();
// build menu
JMenuBar menuBar = new JMenuBar();
JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
toolMenu.add(new OptionAction(Bundle.getMessage("TitleOptions")));
toolMenu.add(new PrintOptionAction());
toolMenu.add(new BuildReportOptionAction());
toolMenu.add(new BackupFilesAction(Bundle.getMessage("Backup")));
toolMenu.add(new RestoreFilesAction(Bundle.getMessage("Restore")));
toolMenu.add(new LoadDemoAction(Bundle.getMessage("LoadDemo")));
toolMenu.add(new ResetAction(Bundle.getMessage("ResetOperations")));
toolMenu.add(new ManageBackupsAction(Bundle.getMessage("ManageAutoBackups")));
menuBar.add(toolMenu);
menuBar.add(new jmri.jmrit.operations.OperationsMenu());
setJMenuBar(menuBar);
// NOI18N
addHelpMenu("package.jmri.jmrit.operations.Operations_Settings", true);
initMinimumSize(new Dimension(Control.panelWidth700, Control.panelHeight500));
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class PaneProgAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (log.isDebugEnabled()) {
log.debug("Pane programmer requested");
}
// create the initial frame that steers
final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameServiceProgrammerSetup"));
f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
// ensure status line is cleared on close so it is normal if re-opened
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
statusLabel.setText(SymbolicProgBundle.getMessage("StateIdle"));
f.windowClosing(we);
}
});
// add the Roster menu
JMenuBar menuBar = new JMenuBar();
// menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
JMenu j = new JMenu(SymbolicProgBundle.getMessage("MenuFile"));
j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintDecoderDefinitions"), f, false));
j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintPreviewDecoderDefinitions"), f, true));
menuBar.add(j);
menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
f.setJMenuBar(menuBar);
// new Loco on programming track
JPanel pane1 = new CombinedLocoSelTreePane(statusLabel, modePane) {
@Override
protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
String title = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { "new decoder" });
if (re != null) {
title = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { re.getId() });
}
JFrame p = new PaneServiceProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", modePane.getProgrammer());
p.pack();
p.setVisible(true);
// f.setVisible(false);
// f.dispose();
}
};
// load primary frame
JPanel tempPane = new JPanel();
tempPane.add(modePane);
f.getContentPane().add(tempPane);
f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
f.getContentPane().add(pane1);
f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
statusLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
f.getContentPane().add(statusLabel);
f.pack();
if (log.isDebugEnabled()) {
log.debug("Tab-Programmer setup created");
}
f.setVisible(true);
}
Aggregations