001package apps;
002
003import java.awt.Dimension;
004import javax.swing.JComponent;
005import javax.swing.JMenuBar;
006import javax.swing.WindowConstants;
007
008import jmri.util.JmriJFrame;
009import jmri.util.swing.JFrameInterface;
010
011/**
012 * Base class for main frame (window) of traditional-style JMRI applications
013 * <p>
014 * This is for launching after the system is initialized, so it does none of
015 * that.
016 *
017 * @author Bob Jacobsen Copyright 2003, 2007, 2008, 2010, 2014
018 * @author Dennis Miller Copyright 2005
019 * @author Giorgio Terdina Copyright 2008
020 * @author Matthew Harris Copyright (C) 2011
021 */
022public class AppsLaunchFrame extends jmri.util.JmriJFrame {
023
024    static String profileFilename;
025
026    public AppsLaunchFrame(AppsLaunchPane containedPane, String name) {
027        super(name);
028
029        // Create a WindowInterface object based on this frame (maybe pass it in?)
030        JFrameInterface wi = new JFrameInterface(this);
031
032        // Create a menu bar
033        menuBar = new JMenuBar();
034
035        // Create menu categories and add to the menu bar, add actions to menus
036        AppsMainMenu.createMenus(menuBar, wi, containedPane, containedPane.windowHelpID());
037
038        setJMenuBar(menuBar);
039        add(containedPane);
040
041        // handle window close
042        setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
043
044        // pack
045        pack();
046
047        // center as default
048        Dimension screen = getToolkit().getScreenSize();
049        Dimension size = getSize();
050        setLocation((screen.width - size.width) / 2, (screen.height - size.height) / 2);
051
052        // then try to load location and size from preferences
053        setFrameLocation();
054    }
055
056    /**
057     * Set the location of the window-specific help for the preferences pane.
058     * Made a separate method so if can be overridden for application specific
059     * preferences help
060     *
061     * @param f the frame to associate with the java help reference
062     * @param l Java Help reference
063     */
064    protected void setPrefsFrameHelp(JmriJFrame f, String l) {
065        f.addHelpMenu(l, true);
066    }
067
068    /**
069     * Provide access to a place where applications can expect the configuration
070     * code to build run-time buttons.
071     *
072     * @see apps.startup.CreateButtonModelFactory
073     * @return null if no such space exists
074     */
075    static public JComponent buttonSpace() {
076        return _buttonSpace;
077    }
078    static JComponent _buttonSpace = null;
079
080    // GUI members
081    private JMenuBar menuBar;
082
083//     private final static Logger log = LoggerFactory.getLogger(AppsLaunchFrame.class);
084}