Search in sources :

Example 56 with JMenuBar

use of javax.swing.JMenuBar in project suite by stupidsing.

the class EditorView method newMenuBar.

private JMenuBar newMenuBar(EditorController controller) {
    JMenuItem newMenuItem = applyDefaults(new JMenuItem("New...", KeyEvent.VK_N));
    newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
    Listen.action(newMenuItem).wire(controller::newFile);
    JMenuItem openMenuItem = applyDefaults(new JMenuItem("Open...", KeyEvent.VK_O));
    openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
    Listen.action(openMenuItem).wire(controller::open);
    JMenuItem saveMenuItem = applyDefaults(new JMenuItem("Save", KeyEvent.VK_S));
    saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    Listen.action(saveMenuItem).wire(controller::save);
    JMenuItem searchMenuItem = applyDefaults(new JMenuItem("Search"));
    searchMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
    Listen.action(searchMenuItem).wire(controller::searchFor);
    JMenuItem exitMenuItem = applyDefaults(new JMenuItem("Close", KeyEvent.VK_C));
    Listen.action(exitMenuItem).wire(controller::close);
    JMenuItem copyMenuItem = applyDefaults(new JMenuItem("Copy"));
    copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK));
    Listen.action(copyMenuItem).wire(event -> controller.copy(false));
    JMenuItem copyAppendMenuItem = applyDefaults(new JMenuItem("Copy Append"));
    copyAppendMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
    Listen.action(copyAppendMenuItem).wire(event -> controller.copy(true));
    JMenuItem pasteMenuItem = applyDefaults(new JMenuItem("Paste"));
    pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK));
    Listen.action(pasteMenuItem).wire(controller::paste);
    JMenuItem formatMenuItem = applyDefaults(new JMenuItem("Format", KeyEvent.VK_F));
    Listen.action(formatMenuItem).wire(controller::format);
    JMenuItem funFilterMenuItem = applyDefaults(new JMenuItem("Functional Filter...", KeyEvent.VK_U));
    Listen.action(funFilterMenuItem).wire(controller::funFilter);
    JMenuItem unixFilterMenuItem = applyDefaults(new JMenuItem("Unix Filter...", KeyEvent.VK_X));
    Listen.action(unixFilterMenuItem).wire(controller::unixFilter);
    JMenuItem leftMenuItem = applyDefaults(new JMenuItem("Left", KeyEvent.VK_L));
    leftMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.ALT_MASK));
    Listen.action(leftMenuItem).wire(controller::left);
    JMenuItem rightMenuItem = applyDefaults(new JMenuItem("Right", KeyEvent.VK_R));
    rightMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
    Listen.action(rightMenuItem).wire(controller::right);
    JMenuItem topMenuItem = applyDefaults(new JMenuItem("Top", KeyEvent.VK_T));
    topMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.ALT_MASK));
    Listen.action(topMenuItem).wire(controller::top);
    JMenuItem bottomMenuItem = applyDefaults(new JMenuItem("Bottom", KeyEvent.VK_B));
    bottomMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.ALT_MASK));
    Listen.action(bottomMenuItem).wire(controller::bottom);
    JMenuItem evalMenuItem = applyDefaults(new JMenuItem("Evaluate", KeyEvent.VK_E));
    Listen.action(evalMenuItem).wire(controller::evaluate);
    JMenuItem evalTypeMenuItem = applyDefaults(new JMenuItem("Evaluate Type", KeyEvent.VK_T));
    Listen.action(evalTypeMenuItem).wire(controller::evaluateType);
    JMenuItem newWindowMenuItem = applyDefaults(new JMenuItem("New Window", KeyEvent.VK_N));
    Listen.action(newWindowMenuItem).wire(controller::newWindow);
    JMenu fileMenu = newMenu(// 
    "File", // 
    KeyEvent.VK_F, newMenuItem, openMenuItem, saveMenuItem, searchMenuItem, exitMenuItem);
    JMenu editMenu = newMenu(// 
    "Edit", // 
    KeyEvent.VK_E, copyMenuItem, copyAppendMenuItem, pasteMenuItem, formatMenuItem, funFilterMenuItem, unixFilterMenuItem);
    JMenu viewMenu = newMenu(// 
    "View", // 
    KeyEvent.VK_V, leftMenuItem, rightMenuItem, topMenuItem, bottomMenuItem);
    JMenu projectMenu = newMenu(// 
    "Project", // 
    KeyEvent.VK_P, evalMenuItem, evalTypeMenuItem);
    JMenu windowMenu = newMenu(// 
    "Window", // 
    KeyEvent.VK_W, newWindowMenuItem, newWindowMenuItem);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(viewMenu);
    menuBar.add(projectMenu);
    menuBar.add(windowMenu);
    return menuBar;
}
Also used : JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 57 with JMenuBar

use of javax.swing.JMenuBar in project vcell by virtualcell.

the class BNGLDebugger method initialize.

@Deprecated
public void initialize() {
    // -------------------------------------------------- bngl panel
    JScrollPane bnglPanel = new JScrollPane();
    bnglTextArea = new JTextArea();
    bnglTextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    // bnglTextArea.setFont(new Font("monospaced", Font.PLAIN, 14));
    lineNumberArea = new JTextArea("1");
    lineNumberArea.setBackground(Color.LIGHT_GRAY);
    lineNumberArea.setEditable(false);
    lineNumberArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bnglTextArea.getDocument().addDocumentListener(new DocumentListener() {

        public String getNr() {
            lines = 1;
            int caretPosition = bnglTextArea.getDocument().getLength();
            Element root = bnglTextArea.getDocument().getDefaultRootElement();
            String nr = "1" + System.getProperty("line.separator");
            for (int i = 2; i < root.getElementIndex(caretPosition) + 2; i++) {
                nr += i + System.getProperty("line.separator");
                lines++;
            }
            return nr;
        }

        @Override
        public void changedUpdate(DocumentEvent de) {
            int oldLines = lines;
            String numbers = getNr();
            if (oldLines != lines) {
                lineNumberArea.setText(numbers);
            }
            lineNumberArea.getHighlighter().removeAllHighlights();
        }

        @Override
        public void insertUpdate(DocumentEvent de) {
            int oldLines = lines;
            String numbers = getNr();
            if (oldLines != lines) {
                lineNumberArea.setText(numbers);
            }
            lineNumberArea.getHighlighter().removeAllHighlights();
        }

        @Override
        public void removeUpdate(DocumentEvent de) {
            int oldLines = lines;
            String numbers = getNr();
            if (oldLines != lines) {
                lineNumberArea.setText(numbers);
            }
            lineNumberArea.getHighlighter().removeAllHighlights();
        }
    });
    bnglPanel.getViewport().add(bnglTextArea);
    bnglPanel.setRowHeaderView(lineNumberArea);
    bnglPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JPanel upperPanel = new JPanel();
    upperPanel.setLayout(new BorderLayout());
    upperPanel.add(bnglPanel, BorderLayout.CENTER);
    // ---------------------------------------------------- exception panel
    JScrollPane exceptionPanel = new JScrollPane();
    exceptionTextArea = new JTextArea();
    exceptionTextArea.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    exceptionTextArea.setFont(new Font("monospaced", Font.PLAIN, 14));
    exceptionPanel.getViewport().add(exceptionTextArea);
    exceptionPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JPanel lowerPanel = new JPanel();
    lowerPanel.setLayout(new BorderLayout());
    lowerPanel.add(exceptionPanel, BorderLayout.CENTER);
    // ---------------------------------------------------- all together now  :)
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(350);
    splitPane.setResizeWeight(0.9);
    splitPane.setTopComponent(upperPanel);
    splitPane.setBottomComponent(lowerPanel);
    // ... Create menubar
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = menuBar.add(new JMenu("File"));
    // fileMenu.setMnemonic('F');
    // fileMenu.add(openAction);       // Note use of actions, not text.
    // fileMenu.add(saveAction);
    // fileMenu.addSeparator();
    fileMenu.add(exitAction);
    JPanel buttonPane = new JPanel();
    buttonParse.addActionListener(this);
    buttonSave.addActionListener(this);
    buttonExit.addActionListener(this);
    buttonPane.add(buttonParse);
    buttonPane.add(buttonSave);
    buttonPane.add(buttonExit);
    JPanel framePanel = new JPanel();
    framePanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    framePanel.add(splitPane, gbc);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    framePanel.add(buttonPane, gbc);
    frame.add(framePanel);
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setName("BnglDebugger");
    frame.setSize(900, 650);
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) DocumentListener(javax.swing.event.DocumentListener) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) Element(javax.swing.text.Element) DocumentEvent(javax.swing.event.DocumentEvent) Font(java.awt.Font) BorderLayout(java.awt.BorderLayout) JSplitPane(javax.swing.JSplitPane) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 58 with JMenuBar

use of javax.swing.JMenuBar in project vcell by virtualcell.

the class VirtualFrapBatchRunFrame method initiateComponents.

/**
 * Initiation of the UI components that is shown in the main window
 */
protected void initiateComponents() {
    toolBar = new ToolBar();
    ToolBarHandler th = new ToolBarHandler();
    toolBar.addToolBarHandler(th);
    mb = new JMenuBar();
    // System.setProperty(PropertyLoader.primarySimDataDirProperty, localWorkspace.getDefaultWorkspaceDirectory());
    // System.setProperty(PropertyLoader.secondarySimDataDirProperty, localWorkspace.getDefaultWorkspaceDirectory());
    System.setProperty(PropertyLoader.exportBaseDirInternalProperty, localWorkspace.getDefaultSimDataDirectory());
    System.setProperty(PropertyLoader.exportBaseURLProperty, "file://" + localWorkspace.getDefaultSimDataDirectory());
    // add components to the main frame
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(toolBar, BorderLayout.NORTH);
    getContentPane().add(statusBarNew, BorderLayout.SOUTH);
    getContentPane().add(getMainSplitPane());
}
Also used : BorderLayout(java.awt.BorderLayout) ToolBar(cbit.vcell.microscopy.gui.ToolBar) JMenuBar(javax.swing.JMenuBar)

Example 59 with JMenuBar

use of javax.swing.JMenuBar in project vcell by virtualcell.

the class VirtualFrapMainFrame method initiateComponents.

/**
 * Initiation of the UI components that is shown in the main window
 */
protected void initiateComponents(DocumentWindowManager documentWindowManager) {
    toolBar = new ToolBar();
    toolBar.setNewAndRunButtonVisible(false);
    ToolBarHandler th = new ToolBarHandler();
    toolBar.addToolBarHandler(th);
    mb = new JMenuBar();
    frapStudyPanel = new FRAPStudyPanel();
    frapStudyPanel.addUndoableEditListener(new UndoableEditListener() {

        public void undoableEditHappened(UndoableEditEvent e) {
            if (e.getEdit().canUndo()) {
                lastUndoableEdit = e.getEdit();
                mUndo.setText(UNDO_ACTION_COMMAND + " " + e.getEdit().getUndoPresentationName());
                mUndo.setEnabled(true);
            } else {
                lastUndoableEdit = null;
                mUndo.setText(UNDO_ACTION_COMMAND);
                mUndo.setEnabled(false);
            }
        }
    });
    // System.setProperty(PropertyLoader.primarySimDataDirProperty, localWorkspace.getDefaultWorkspaceDirectory());
    // System.setProperty(PropertyLoader.secondarySimDataDirProperty, localWorkspace.getDefaultWorkspaceDirectory());
    System.setProperty(PropertyLoader.exportBaseDirInternalProperty, localWorkspace.getDefaultSimDataDirectory());
    System.setProperty(PropertyLoader.exportBaseURLProperty, "file://" + localWorkspace.getDefaultSimDataDirectory());
    frapStudyPanel.setLocalWorkspace(localWorkspace);
    frapStudyPanel.setFRAPWorkspace(frapWorkspace);
    frapStudyPanel.setDocumentWindowManager(documentWindowManager);
    // add components to the main frame
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(toolBar, BorderLayout.NORTH);
    getContentPane().add(statusBarNew, BorderLayout.SOUTH);
    getContentPane().add(frapStudyPanel);
}
Also used : UndoableEditListener(javax.swing.event.UndoableEditListener) BorderLayout(java.awt.BorderLayout) UndoableEditEvent(javax.swing.event.UndoableEditEvent) JMenuBar(javax.swing.JMenuBar)

Example 60 with JMenuBar

use of javax.swing.JMenuBar in project vcell by virtualcell.

the class TopLevel method init.

/**
 * @return last window to receive focus, or null if none
 */
// private static TopLevel lastFocused( ) {
// Optional<WeakReference<TopLevel>> first = liveWindows( ).findFirst();
// if (first.isPresent()) {
// return first.get( ).get( );
// }
// return null;
// }
private void init() {
    // TopLevel lastWindow = lastFocused();
    // tops.addFirst(new WeakReference<TopLevel>(this));
    // addWindowFocusListener(new FocusWatch());
    // 
    TestPanel tp = new TestPanel();
    tp.setHwindow(this);
    getContentPane().add(tp, BorderLayout.CENTER);
    JMenuBar menuBar = new JMenuBar();
    getContentPane().add(menuBar, BorderLayout.NORTH);
    menuBar.add(super.createWindowMenu(true));
    pack();
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setLocationRelativeTo(null);
    System.out.println(SwingUtilities.isDescendingFrom(this, tp));
    System.out.println(SwingUtilities.isDescendingFrom(tp, this));
}
Also used : JMenuBar(javax.swing.JMenuBar)

Aggregations

JMenuBar (javax.swing.JMenuBar)119 JMenu (javax.swing.JMenu)83 JMenuItem (javax.swing.JMenuItem)45 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)30 JPanel (javax.swing.JPanel)28 BoxLayout (javax.swing.BoxLayout)25 Dimension (java.awt.Dimension)23 JFrame (javax.swing.JFrame)17 JScrollPane (javax.swing.JScrollPane)15 JLabel (javax.swing.JLabel)14 JButton (javax.swing.JButton)13 JmriJFrame (jmri.util.JmriJFrame)12 GridBagLayout (java.awt.GridBagLayout)11 BorderLayout (java.awt.BorderLayout)10 JSeparator (javax.swing.JSeparator)10 AbstractAction (javax.swing.AbstractAction)9 FlowLayout (java.awt.FlowLayout)6 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)6 JPopupMenu (javax.swing.JPopupMenu)6