use of javax.swing.JMenuBar in project JMRI by JMRI.
the class SignalMastLogicTableAction method setMenuBar.
/**
* Insert a table specific Tools menu.
* Account for the Window and Help menus, which are already added to the menu bar
* as part of the creation of the JFrame, by adding the Tools menu 2 places earlier
* unless the table is part of the ListedTableFrame, that adds the Help menu later on.
* @param f the JFrame of this table
*/
@Override
public void setMenuBar(BeanTableFrame f) {
// needed for anonymous ActionListener class
final jmri.util.JmriJFrame finalF = f;
JMenuBar menuBar = f.getJMenuBar();
// count the number of menus to insert the TableMenu before 'Window' and 'Help'
int pos = menuBar.getMenuCount() - 1;
int offset = 1;
log.debug("setMenuBar number of menu items = " + pos);
for (int i = 0; i <= pos; i++) {
if (menuBar.getComponent(i) instanceof JMenu) {
if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuHelp"))) {
// correct for use as part of ListedTableAction where the Help Menu is not yet present
offset = -1;
}
}
}
JMenu pathMenu = new JMenu(Bundle.getMessage("MenuTools"));
menuBar.add(pathMenu, pos + offset);
JMenuItem item = new JMenuItem(Bundle.getMessage("MenuItemAutoGen"));
pathMenu.add(item);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
autoCreatePairs(finalF);
}
});
item = new JMenuItem(Bundle.getMessage("MenuItemAutoGenSections"));
pathMenu.add(item);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
((jmri.managers.DefaultSignalMastLogicManager) InstanceManager.getDefault(jmri.SignalMastLogicManager.class)).generateSection();
JOptionPane.showMessageDialog(null, Bundle.getMessage("SectionGenerationComplete"));
}
});
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class SignalMastTableAction method setMenuBar.
/**
* Insert a table specific Tools menu.
* Account for the Window and Help menus, which are already added to the menu bar
* as part of the creation of the JFrame, by adding the Tools menu 2 places earlier
* unless the table is part of the ListedTableFrame, that adds the Help menu later on.
* @param f the JFrame of this table
*/
@Override
public void setMenuBar(BeanTableFrame f) {
JMenuBar menuBar = f.getJMenuBar();
// count the number of menus to insert the TableMenu before 'Window' and 'Help'
int pos = menuBar.getMenuCount() - 1;
int offset = 1;
log.debug("setMenuBar number of menu items = " + pos);
for (int i = 0; i <= pos; i++) {
if (menuBar.getComponent(i) instanceof JMenu) {
if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuHelp"))) {
// correct for use as part of ListedTableAction where the Help Menu is not yet present
offset = -1;
}
}
}
JMenu pathMenu = new JMenu(Bundle.getMessage("MenuTools"));
menuBar.add(pathMenu, pos + offset);
JMenuItem item = new JMenuItem(Bundle.getMessage("MenuItemRepeaters"));
pathMenu.add(item);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jmri.jmrit.beantable.signalmast.SignalMastRepeaterJFrame frame = new jmri.jmrit.beantable.signalmast.SignalMastRepeaterJFrame();
frame.setVisible(true);
}
});
}
use of javax.swing.JMenuBar in project nhin-d by DirectProject.
the class SimpleTextPolicyBuilder method initUI.
private void initUI() {
// build the menu bar
menuBar = new JMenuBar();
// build the file menu
JMenu fileMenu = new JMenu("File");
quit = new JMenuItem("Quit");
save = new JMenuItem("Save");
saveAs = new JMenuItem("SaveAs");
openFile = new JMenuItem("Open");
fileMenu.add(openFile);
fileMenu.addSeparator();
fileMenu.add(save);
fileMenu.add(saveAs);
//fileMenu.add(quit);
menuBar.add(fileMenu);
this.setJMenuBar(menuBar);
getContentPane().setLayout(new BorderLayout());
editPanel = new EditorPanel();
getContentPane().add(editPanel);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class ThreePaneTLRWindow method addMainMenuBar.
protected void addMainMenuBar(String menuFile) {
if (menuFile == null) {
return;
}
JMenuBar menuBar = new JMenuBar();
JMenu[] menus = JMenuUtil.loadMenu(menuFile, rightTopWI, null);
for (JMenu j : menus) {
menuBar.add(j);
}
setJMenuBar(menuBar);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class AddEntryExitPairFrame method initComponents.
/**
* Create and set an AddEntryExitPairFrame on a given LE panel and add menuItems.
*
* @param panel the LE panel on which to create the NX frame
* @throws Exception when an error prevents creating the panel
*/
public void initComponents(LayoutEditor panel) throws Exception {
// the following code sets the frame's initial state
nxPanel = new AddEntryExitPairPanel(panel);
setTitle(Bundle.getMessage("AddEntryExitPoints"));
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
getContentPane().add(nxPanel);
//getJMenuBar();
JMenuBar menuBar = new JMenuBar();
// reuse existing key in jmrit.Bundle
JMenuItem options = new JMenuItem(Bundle.getMessage("MenuOptions"));
menuBar.add(options);
options.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
nxPanel.optionWindow(event);
}
});
setJMenuBar(menuBar);
addHelpMenu("package.jmri.jmrit.signalling.EntryExitFrame", true);
// pack for display
pack();
}
Aggregations