Search in sources :

Example 1 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project processing by processing.

the class Toolkit method newJCheckBoxMenuItem.

public static JCheckBoxMenuItem newJCheckBoxMenuItem(String title, int what) {
    JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(title);
    int modifiers = awtToolkit.getMenuShortcutKeyMask();
    menuItem.setAccelerator(KeyStroke.getKeyStroke(what, modifiers));
    return menuItem;
}
Also used : JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 2 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem 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 3 with JCheckBoxMenuItem

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

the class ColumnSelectionPanel method showColumnSelectionPopup.

public static void showColumnSelectionPopup(ColumnSelectionModel[] columns, Component c) {
    JPopupMenu popup = new JPopupMenu();
    for (int col = 0; col < columns.length; col++) {
        final ColumnSelectionModel column = columns[col];
        final JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem();
        checkBox.setText(column.getName());
        checkBox.setSelected(column.isSelected());
        checkBox.setEnabled(column.isEnabled());
        checkBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {
                column.setSelected(checkBox.isSelected());
            }
        });
        popup.add(checkBox);
    }
    popup.show(c, 8, 8);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 4 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem 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 JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project pcgen by PCGen.

the class JDynamicTable method createMenuItem.

private JCheckBoxMenuItem createMenuItem(TableColumn column) {
    JCheckBoxMenuItem item = new JCheckBoxMenuItem();
    boolean visible = dynamicColumnModel.isVisible(column);
    item.setSelected(visible);
    item.setAction(new MenuAction(column, visible));
    return item;
}
Also used : JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Aggregations

JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)41 ActionEvent (java.awt.event.ActionEvent)16 JMenuItem (javax.swing.JMenuItem)15 ActionListener (java.awt.event.ActionListener)13 JMenu (javax.swing.JMenu)12 JPopupMenu (javax.swing.JPopupMenu)11 AbstractAction (javax.swing.AbstractAction)8 JMenuBar (javax.swing.JMenuBar)6 JSeparator (javax.swing.JSeparator)5 JTableHeader (javax.swing.table.JTableHeader)4 TableColumn (javax.swing.table.TableColumn)4 Action (javax.swing.Action)3 JButton (javax.swing.JButton)3 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)3 Component (java.awt.Component)2 ItemEvent (java.awt.event.ItemEvent)2 HashMap (java.util.HashMap)2 ButtonGroup (javax.swing.ButtonGroup)2 JFrame (javax.swing.JFrame)2 JOptionPane (javax.swing.JOptionPane)2