Search in sources :

Example 1 with JMenuBar

use of javax.swing.JMenuBar in project jadx by skylot.

the class MainWindow method initMenuAndToolbar.

private void initMenuAndToolbar() {
    Action openAction = new AbstractAction(NLS.str("file.open"), ICON_OPEN) {

        @Override
        public void actionPerformed(ActionEvent e) {
            openFile();
        }
    };
    openAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.open"));
    openAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
    Action saveAllAction = new AbstractAction(NLS.str("file.save_all"), ICON_SAVE_ALL) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAll(false);
        }
    };
    saveAllAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.save_all"));
    saveAllAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
    Action exportAction = new AbstractAction(NLS.str("file.export_gradle"), ICON_EXPORT) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAll(true);
        }
    };
    exportAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.export_gradle"));
    exportAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK));
    JMenu recentFiles = new JMenu(NLS.str("menu.recent_files"));
    recentFiles.addMenuListener(new RecentFilesMenuListener(recentFiles));
    Action prefsAction = new AbstractAction(NLS.str("menu.preferences"), ICON_PREF) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new JadxSettingsWindow(MainWindow.this, settings).setVisible(true);
        }
    };
    prefsAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.preferences"));
    prefsAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action exitAction = new AbstractAction(NLS.str("file.exit"), ICON_CLOSE) {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };
    isFlattenPackage = settings.isFlattenPackage();
    flatPkgMenuItem = new JCheckBoxMenuItem(NLS.str("menu.flatten"), ICON_FLAT_PKG);
    flatPkgMenuItem.setState(isFlattenPackage);
    Action syncAction = new AbstractAction(NLS.str("menu.sync"), ICON_SYNC) {

        @Override
        public void actionPerformed(ActionEvent e) {
            syncWithEditor();
        }
    };
    syncAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.sync"));
    syncAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_DOWN_MASK));
    Action textSearchAction = new AbstractAction(NLS.str("menu.text_search"), ICON_SEARCH) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new SearchDialog(MainWindow.this, EnumSet.of(SearchOptions.CODE)).setVisible(true);
        }
    };
    textSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.text_search"));
    textSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action clsSearchAction = new AbstractAction(NLS.str("menu.class_search"), ICON_FIND) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new SearchDialog(MainWindow.this, EnumSet.of(SearchOptions.CLASS)).setVisible(true);
        }
    };
    clsSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.class_search"));
    clsSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK));
    Action deobfAction = new AbstractAction(NLS.str("preferences.deobfuscation"), ICON_DEOBF) {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleDeobfuscation();
        }
    };
    deobfAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("preferences.deobfuscation"));
    deobfAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    deobfToggleBtn = new JToggleButton(deobfAction);
    deobfToggleBtn.setSelected(settings.isDeobfuscationOn());
    deobfToggleBtn.setText("");
    deobfMenuItem = new JCheckBoxMenuItem(deobfAction);
    deobfMenuItem.setState(settings.isDeobfuscationOn());
    Action logAction = new AbstractAction(NLS.str("menu.log"), ICON_LOG) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new LogViewer(settings).setVisible(true);
        }
    };
    logAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.log"));
    logAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action aboutAction = new AbstractAction(NLS.str("menu.about")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutDialog().setVisible(true);
        }
    };
    Action backAction = new AbstractAction(NLS.str("nav.back"), ICON_BACK) {

        @Override
        public void actionPerformed(ActionEvent e) {
            tabbedPane.navBack();
        }
    };
    backAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.back"));
    backAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    Action forwardAction = new AbstractAction(NLS.str("nav.forward"), ICON_FORWARD) {

        @Override
        public void actionPerformed(ActionEvent e) {
            tabbedPane.navForward();
        }
    };
    forwardAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.forward"));
    forwardAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    JMenu file = new JMenu(NLS.str("menu.file"));
    file.setMnemonic(KeyEvent.VK_F);
    file.add(openAction);
    file.add(saveAllAction);
    file.add(exportAction);
    file.addSeparator();
    file.add(recentFiles);
    file.addSeparator();
    file.add(prefsAction);
    file.addSeparator();
    file.add(exitAction);
    JMenu view = new JMenu(NLS.str("menu.view"));
    view.setMnemonic(KeyEvent.VK_V);
    view.add(flatPkgMenuItem);
    view.add(syncAction);
    JMenu nav = new JMenu(NLS.str("menu.navigation"));
    nav.setMnemonic(KeyEvent.VK_N);
    nav.add(textSearchAction);
    nav.add(clsSearchAction);
    nav.addSeparator();
    nav.add(backAction);
    nav.add(forwardAction);
    JMenu tools = new JMenu(NLS.str("menu.tools"));
    tools.setMnemonic(KeyEvent.VK_T);
    tools.add(deobfMenuItem);
    tools.add(logAction);
    JMenu help = new JMenu(NLS.str("menu.help"));
    help.setMnemonic(KeyEvent.VK_H);
    help.add(aboutAction);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(file);
    menuBar.add(view);
    menuBar.add(nav);
    menuBar.add(tools);
    menuBar.add(help);
    setJMenuBar(menuBar);
    flatPkgButton = new JToggleButton(ICON_FLAT_PKG);
    flatPkgButton.setSelected(isFlattenPackage);
    ActionListener flatPkgAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleFlattenPackage();
        }
    };
    flatPkgMenuItem.addActionListener(flatPkgAction);
    flatPkgButton.addActionListener(flatPkgAction);
    flatPkgButton.setToolTipText(NLS.str("menu.flatten"));
    updateLink = new Link("", JadxUpdate.JADX_RELEASES_URL);
    updateLink.setVisible(false);
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(openAction);
    toolbar.add(saveAllAction);
    toolbar.add(exportAction);
    toolbar.addSeparator();
    toolbar.add(syncAction);
    toolbar.add(flatPkgButton);
    toolbar.addSeparator();
    toolbar.add(textSearchAction);
    toolbar.add(clsSearchAction);
    toolbar.addSeparator();
    toolbar.add(backAction);
    toolbar.add(forwardAction);
    toolbar.addSeparator();
    toolbar.add(deobfToggleBtn);
    toolbar.addSeparator();
    toolbar.add(logAction);
    toolbar.addSeparator();
    toolbar.add(prefsAction);
    toolbar.addSeparator();
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(updateLink);
    mainPanel.add(toolbar, BorderLayout.NORTH);
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) JadxSettingsWindow(jadx.gui.settings.JadxSettingsWindow) JToolBar(javax.swing.JToolBar) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar) Link(jadx.gui.utils.Link)

Example 2 with JMenuBar

use of javax.swing.JMenuBar in project gephi by gephi.

the class BannerRootPanelLayout method layoutContainer.

@Override
public void layoutContainer(Container parent) {
    JRootPane rootPane = (JRootPane) parent;
    //        hideMenu(rootPane);
    Rectangle bounds = rootPane.getBounds();
    Insets insets = rootPane.getInsets();
    int y = insets.top;
    int x = insets.left;
    int w = bounds.width - insets.right - insets.left;
    int h = bounds.height - insets.top - insets.bottom;
    if (rootPane.getLayeredPane() != null) {
        rootPane.getLayeredPane().setBounds(x, y, w, h);
    }
    if (rootPane.getGlassPane() != null) {
        rootPane.getGlassPane().setBounds(x, y, w, h);
    }
    if (rootPane.getJMenuBar() != null && rootPane.getJMenuBar().isVisible()) {
        JMenuBar menu = rootPane.getJMenuBar();
        Dimension size = menu.getPreferredSize();
        menu.setBounds(x, y, w, size.height);
        y += size.height;
    }
    if (_toolbar != null) {
        Dimension size = _toolbar.getPreferredSize();
        _toolbar.setBounds(x, y, w, size.height);
        y += size.height;
    }
    if (rootPane.getContentPane() != null) {
        int height = h - y;
        if (height < 0) {
            height = 0;
        }
        rootPane.getContentPane().setBounds(x, y, w, height);
    }
}
Also used : Insets(java.awt.Insets) Rectangle(java.awt.Rectangle) JRootPane(javax.swing.JRootPane) Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar)

Example 3 with JMenuBar

use of javax.swing.JMenuBar in project binnavi by google.

the class CAbstractMenuBuilder method createMenus.

/**
   * Creates all menus.
   */
private void createMenus() {
    // TODO: Old menus must be disposed before creating new ones
    m_mainMenu = new JMenuBar();
    m_mainMenu.add(createBinNaviMenu());
    final JMenu menu = getMenu();
    if (menu != null) {
        createMenu(menu);
        m_mainMenu.add(menu);
    }
    m_mainMenu.add(createPluginsMenu());
    m_mainMenu.add(createSettingsMenu());
    m_mainMenu.add(createAboutMenu());
    m_popupMenu = new JPopupMenu();
    createMenu(m_popupMenu);
}
Also used : JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) JPopupMenu(javax.swing.JPopupMenu)

Example 4 with JMenuBar

use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 5 with JMenuBar

use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.

the class MisplacedBorder method run.

@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);
    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();
    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
Also used : JFrame(javax.swing.JFrame) IOException(java.io.IOException) File(java.io.File) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) BufferedImage(java.awt.image.BufferedImage)

Aggregations

JMenuBar (javax.swing.JMenuBar)108 JMenu (javax.swing.JMenu)77 JMenuItem (javax.swing.JMenuItem)42 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)30 JPanel (javax.swing.JPanel)27 BoxLayout (javax.swing.BoxLayout)25 Dimension (java.awt.Dimension)23 JFrame (javax.swing.JFrame)17 JLabel (javax.swing.JLabel)14 JScrollPane (javax.swing.JScrollPane)14 JButton (javax.swing.JButton)13 JmriJFrame (jmri.util.JmriJFrame)12 GridBagLayout (java.awt.GridBagLayout)10 JSeparator (javax.swing.JSeparator)10 AbstractAction (javax.swing.AbstractAction)9 BorderLayout (java.awt.BorderLayout)6 FlowLayout (java.awt.FlowLayout)6 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)6 DecoderFile (jmri.jmrit.decoderdefn.DecoderFile)6