use of javax.swing.JMenuBar in project jgnash by ccavanaugh.
the class ActionParser method createMenuBar.
public JMenuBar createMenuBar(final String id) {
JMenuBar menuBar = new JMenuBar();
Object o = actionTrees.get(id);
if (o != null) {
ActionNode node = (ActionNode) o;
for (int i = 0; i < node.size(); i++) {
JMenuItem item = createMenuItem(node.getChildAt(i));
if (item instanceof JMenu) {
menuBar.add((JMenu) item);
} else {
log.log(Level.WARNING, "{0} invalid", item.toString());
}
}
} else {
log.log(Level.WARNING, "{0} not found", id);
}
return menuBar;
}
use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.
the class MetalworksFrame method buildMenus.
protected void buildMenus() {
menuBar = new JMenuBar();
menuBar.setOpaque(true);
JMenu file = buildFileMenu();
JMenu edit = buildEditMenu();
JMenu views = buildViewsMenu();
JMenu speed = buildSpeedMenu();
JMenu help = buildHelpMenu();
// load a theme from a text file
MetalTheme myTheme = null;
try {
InputStream istream = getClass().getResourceAsStream("/resources/MyTheme.theme");
myTheme = new PropertiesMetalTheme(istream);
} catch (NullPointerException e) {
System.out.println(e);
}
// build an array of themes
MetalTheme[] themes = { new OceanTheme(), new DefaultMetalTheme(), new GreenMetalTheme(), new AquaMetalTheme(), new KhakiMetalTheme(), new DemoMetalTheme(), new ContrastMetalTheme(), new BigContrastMetalTheme(), myTheme };
// put the themes in a menu
JMenu themeMenu = new MetalThemeMenu("Theme", themes);
menuBar.add(file);
menuBar.add(edit);
menuBar.add(views);
menuBar.add(themeMenu);
menuBar.add(speed);
menuBar.add(help);
setJMenuBar(menuBar);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class JmriJFrame method addHelpMenu.
/**
* Add a standard help menu, including window specific help item.
*
* @param ref JHelp reference for the desired window-specific help page
* @param direct true if the help menu goes directly to the help system,
* such as when there are no items in the help menu
*/
public void addHelpMenu(String ref, boolean direct) {
// only works if no menu present?
JMenuBar bar = getJMenuBar();
if (bar == null) {
bar = new JMenuBar();
}
// add Window menu
// * GT 28-AUG-2008 Added window menu
bar.add(new WindowMenu(this));
// add Help menu
jmri.util.HelpUtil.helpMenu(bar, ref, direct);
setJMenuBar(bar);
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class JmriJInternalFrameInterface method show.
@Override
public void show(final jmri.util.swing.JmriPanel child, jmri.util.swing.JmriAbstractAction act, Hint hint) {
// create new internal frame
JInternalFrame frame = new JInternalFrame(child.getTitle(), //resizable
true, //closable
true, //maximizable
true, //iconifiable
true);
frame.setLocation(50, 50);
// add gui object, responsible for own layout
frame.add(child);
// add menus if requested
JMenuBar bar = frame.getJMenuBar();
if (bar == null) {
bar = new JMenuBar();
}
List<JMenu> list = child.getMenus();
for (JMenu menu : list) {
bar.add(menu);
}
// to code in JmriJFrame
if (child.getHelpTarget() != null) {
// add Help menu
jmri.util.HelpUtil.helpMenu(bar, child.getHelpTarget(), true);
}
frame.setJMenuBar(bar);
// set title if available
if (child.getTitle() != null) {
frame.setTitle(child.getTitle());
}
// arrange to run dispose on close
//frame.addWindowListener( new java.awt.event.WindowAdapter(){
// jmri.util.swing.JmriPanel c;
// { c = child; }
// public void windowClosed(java.awt.event.WindowEvent e) {
// c.dispose();
// }
//});
// add to desktop
frame.pack();
frame.setVisible(true);
desktop.add(frame);
frame.moveToFront();
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class JmriJFrameInterface method show.
@Override
public void show(final JmriPanel child, JmriAbstractAction act, Hint hint) {
// display cached frame if available
JmriJFrame frame = frames.get(child);
if (frame != null) {
frame.setVisible(true);
return;
}
// create frame
frame = new jmri.util.JmriJFrame();
// cache if single instance
if (!child.isMultipleInstances()) {
frames.put(child, frame);
}
// add gui object, responsible for own layout
frame.add(child);
// add menus if requested
List<JMenu> list = child.getMenus();
JMenuBar bar = frame.getJMenuBar();
if (bar == null) {
bar = new JMenuBar();
}
for (JMenu menu : list) {
bar.add(menu);
}
frame.setJMenuBar(bar);
// add help menu if requested
if (child.getHelpTarget() != null) {
frame.addHelpMenu(child.getHelpTarget(), true);
}
// set title if available
if (child.getTitle() != null) {
frame.setTitle(child.getTitle());
}
// if multi-instance, arrange to run dispose on close
if (child.isMultipleInstances()) {
frame.addWindowListener(new java.awt.event.WindowAdapter() {
jmri.util.swing.JmriPanel c;
{
c = child;
}
@Override
public void windowClosed(java.awt.event.WindowEvent e) {
c.dispose();
}
});
}
// pack and show
frame.pack();
frame.setVisible(true);
}
Aggregations