Search in sources :

Example 6 with MenuBar

use of java.awt.MenuBar in project jdk8u_jdk by JetBrains.

the class CMenu method createModel.

@Override
long createModel() {
    CMenuComponent parent = (CMenuComponent) LWCToolkit.targetToPeer(getTarget().getParent());
    if (parent instanceof CMenu) {
        return parent.executeGet(this::nativeCreateSubMenu);
    }
    if (parent instanceof CMenuBar) {
        MenuBar parentContainer = (MenuBar) getTarget().getParent();
        boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget();
        int insertionLocation = ((CMenuBar) parent).getNextInsertionIndex();
        return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu, insertionLocation));
    }
    throw new InternalError("Parent must be CMenu or CMenuBar");
}
Also used : MenuBar(java.awt.MenuBar)

Example 7 with MenuBar

use of java.awt.MenuBar in project litiengine by gurkenlabs.

the class Program method setupInterface.

private static void setupInterface() {
    MenuBar menuBar = new MenuBar();
    JFrame window = ((JFrame) Game.getScreenManager());
    Game.onTerminating(s -> {
        boolean terminate = notifyPendingChanges();
        if (terminate) {
            getUserPreferences().setFrameState(((JFrame) Game.getScreenManager()).getExtendedState());
        }
        return terminate;
    });
    window.setResizable(true);
    window.setMenuBar(menuBar);
    if (userPreferences.getWidth() != 0 && userPreferences.getHeight() != 0) {
        window.setSize(userPreferences.getWidth(), userPreferences.getHeight());
    }
    if (userPreferences.getFrameState() != JFrame.ICONIFIED && userPreferences.getFrameState() != JFrame.NORMAL) {
        window.setExtendedState(userPreferences.getFrameState());
    }
    Canvas canvas = Game.getScreenManager().getRenderComponent();
    canvas.setFocusable(true);
    canvas.setSize((int) (window.getSize().width * 0.75), window.getSize().height);
    window.remove(canvas);
    JPanel renderPane = new JPanel(new BorderLayout());
    renderPane.add(canvas);
    renderPane.setMinimumSize(new Dimension(300, 0));
    initCanvasPopupMenu(canvas);
    JPanel contentPane = new JPanel(new BorderLayout());
    window.setContentPane(contentPane);
    horizontalScroll = new JScrollBar(JScrollBar.HORIZONTAL);
    renderPane.add(horizontalScroll, BorderLayout.SOUTH);
    verticalScroll = new JScrollBar(JScrollBar.VERTICAL);
    renderPane.add(verticalScroll, BorderLayout.EAST);
    horizontalScroll.addAdjustmentListener(e -> {
        if (EditorScreen.instance().getMapComponent().isLoading()) {
            return;
        }
        Point2D newFocus = new Point2D.Double(horizontalScroll.getValue(), Game.getCamera().getFocus().getY());
        Game.getCamera().setFocus(newFocus);
    });
    verticalScroll.addAdjustmentListener(e -> {
        if (EditorScreen.instance().getMapComponent().isLoading()) {
            return;
        }
        Point2D newFocus = new Point2D.Double(Game.getCamera().getFocus().getX(), verticalScroll.getValue());
        Game.getCamera().setFocus(newFocus);
    });
    MapObjectPanel mapEditorPanel = new MapObjectPanel();
    MapSelectionPanel mapSelectionPanel = new MapSelectionPanel();
    JSplitPane mapWrap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mapWrap.setMinimumSize(new Dimension(300, 0));
    mapWrap.setBottomComponent(mapEditorPanel);
    mapWrap.setTopComponent(mapSelectionPanel);
    mapWrap.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setSelectionEditSplitter(mapWrap.getDividerLocation()));
    if (userPreferences.getSelectionEditSplitter() != 0) {
        mapWrap.setDividerLocation(userPreferences.getSelectionEditSplitter());
    }
    JPanel bottomPanel = new JPanel(new BorderLayout());
    JTabbedPane bottomTab = new JTabbedPane();
    bottomTab.addTab(Resources.get("assettree_assets"), initAssetsComponent());
    bottomTab.addTab("Console", initConsole());
    bottomTab.setIconAt(0, new ImageIcon(Resources.getImage("asset.png")));
    bottomTab.setIconAt(1, new ImageIcon(Resources.getImage("console.png")));
    bottomPanel.add(bottomTab, BorderLayout.CENTER);
    statusBar = new JLabel("");
    statusBar.setPreferredSize(new Dimension(0, 16));
    statusBar.setFont(new Font(ConsoleLogHandler.CONSOLE_FONT, Font.PLAIN, 10));
    bottomPanel.add(statusBar, BorderLayout.SOUTH);
    EditorScreen.instance().getMapComponent().onSelectionChanged(selection -> {
        if (selection.isEmpty()) {
            statusBar.setText("");
        } else {
            statusBar.setText(" " + selection.size() + " selected objects");
        }
    });
    JSplitPane rendersplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, renderPane, bottomPanel);
    if (userPreferences.getBottomSplitter() != 0) {
        rendersplit.setDividerLocation(userPreferences.getBottomSplitter());
    } else {
        rendersplit.setDividerLocation((int) (window.getSize().height * 0.75));
    }
    rendersplit.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setBottomSplitter(rendersplit.getDividerLocation()));
    rendersplit.setContinuousLayout(true);
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rendersplit, mapWrap);
    split.setContinuousLayout(true);
    split.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            userPreferences.setWidth(window.getWidth());
            userPreferences.setHeight(window.getHeight());
        }
    });
    split.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setMainSplitter(split.getDividerLocation()));
    contentPane.add(split, BorderLayout.CENTER);
    split.setDividerLocation(userPreferences.getMainSplitterPosition() != 0 ? userPreferences.getMainSplitterPosition() : (int) (window.getSize().width * 0.75));
    JToolBar toolbar = initToolBar();
    contentPane.add(toolbar, BorderLayout.NORTH);
    EditorScreen.instance().setMapEditorPanel(mapEditorPanel);
    EditorScreen.instance().setMapSelectionPanel(mapSelectionPanel);
    Menu mnFile = initFileMenu();
    menuBar.add(mnFile);
    Menu mnView = initViewMenu();
    menuBar.add(mnView);
    Menu mnProject = initProjectMenu();
    menuBar.add(mnProject);
    Menu mnMap = initMapMenu();
    menuBar.add(mnMap);
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) Canvas(java.awt.Canvas) JTabbedPane(javax.swing.JTabbedPane) MenuBar(java.awt.MenuBar) MapObjectPanel(de.gurkenlabs.utiliti.swing.panels.MapObjectPanel) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JToolBar(javax.swing.JToolBar) Font(java.awt.Font) JScrollBar(javax.swing.JScrollBar) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) Point2D(java.awt.geom.Point2D) ComponentEvent(java.awt.event.ComponentEvent) PopupMenu(java.awt.PopupMenu) Menu(java.awt.Menu) JPopupMenu(javax.swing.JPopupMenu) JSplitPane(javax.swing.JSplitPane) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 8 with MenuBar

use of java.awt.MenuBar in project fql by CategoricalData.

the class GUI method makeGUI.

@SuppressWarnings({})
public static Pair<JPanel, MenuBar> makeGUI(JFrame frame) {
    topFrame = frame;
    MenuBar menuBar = new MenuBar();
    Menu fileMenu = makeFileMenu();
    Menu editMenu = makeEditMenu();
    Menu toolsMenu = makesToolsMenu();
    Menu helpMenu = new Menu("Help");
    MenuItem aboutItem = new MenuItem("Help/About");
    helpMenu.add(aboutItem);
    aboutItem.addActionListener(e -> IdeOptions.showAbout());
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(toolsMenu);
    Menu aqlMenu = populateAql();
    menuBar.add(aqlMenu);
    // Menu legacyMenu = new Menu("Legacy");
    Menu fqlMenu = new Menu("FQL");
    Menu fqlppMenu = new Menu("FQL++");
    Menu oplMenu = new Menu("OPL");
    Menu fpqlMenu = new Menu("FPQL");
    populateFql(fqlMenu);
    populateFqlpp(fqlppMenu);
    populateFpql(fpqlMenu);
    populateOpl(oplMenu);
    menuBar.add(fqlMenu);
    menuBar.add(fqlppMenu);
    menuBar.add(fpqlMenu);
    menuBar.add(oplMenu);
    menuBar.add(helpMenu);
    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout());
    JPanel toolBar = makeToolBar();
    pan.add(toolBar, BorderLayout.PAGE_START);
    pan.add(editors, BorderLayout.CENTER);
    return new Pair<>(pan, menuBar);
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) MenuBar(java.awt.MenuBar) MenuItem(java.awt.MenuItem) Menu(java.awt.Menu) Pair(catdata.Pair)

Example 9 with MenuBar

use of java.awt.MenuBar in project ffx by mjschnie.

the class ModelingShell method initMenus.

/**
 * Update the shell menu items.
 */
private void initMenus() {
    JFrame frame = (JFrame) this.getFrame();
    MenuBar menuBar = frame.getMenuBar();
    /**
     * Remove "Capture Std. Out", "Capture Std. Error" & "Detached Output"
     * from the View menu.
     */
    Menu menu = menuBar.getMenu(2);
    menu.remove(5);
    menu.remove(5);
    menu.remove(9);
    /**
     * Edit the Script menu.
     */
    menu = menuBar.getMenu(4);
    menu.remove(4);
    menu.remove(4);
    menu.remove(4);
    menu.remove(5);
    menu.remove(7);
}
Also used : JFrame(javax.swing.JFrame) MenuBar(java.awt.MenuBar) Menu(java.awt.Menu)

Example 10 with MenuBar

use of java.awt.MenuBar in project TrakEM2 by trakem2.

the class Utils method restoreMenuBar.

/**
 *Restore ImageJ's MenuBar
 */
public static final void restoreMenuBar() {
    final MenuBar menu_bar = Menus.getMenuBar();
    final int n_menus = menu_bar.getMenuCount();
    for (int i = 0; i < n_menus; i++) {
        final Menu menu = menu_bar.getMenu(i);
        restoreMenu(menu);
    }
// make sure there isn't a null menu bar
// WindowManager.getCurrentWindow().setMenuBar(menu_bar);
}
Also used : MenuBar(java.awt.MenuBar) JMenu(javax.swing.JMenu) Menu(java.awt.Menu) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

MenuBar (java.awt.MenuBar)10 Menu (java.awt.Menu)7 Dimension (java.awt.Dimension)4 Frame (java.awt.Frame)3 MemoryImageSource (java.awt.image.MemoryImageSource)3 JFrame (javax.swing.JFrame)3 JPanel (javax.swing.JPanel)3 BorderLayout (java.awt.BorderLayout)2 MenuItem (java.awt.MenuItem)2 JPopupMenu (javax.swing.JPopupMenu)2 Pair (catdata.Pair)1 MapObjectPanel (de.gurkenlabs.utiliti.swing.panels.MapObjectPanel)1 Canvas (java.awt.Canvas)1 FileDialog (java.awt.FileDialog)1 Font (java.awt.Font)1 HeadlessException (java.awt.HeadlessException)1 MenuShortcut (java.awt.MenuShortcut)1 PopupMenu (java.awt.PopupMenu)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1