Example usage for javax.swing JRadioButtonMenuItem JRadioButtonMenuItem

List of usage examples for javax.swing JRadioButtonMenuItem JRadioButtonMenuItem

Introduction

In this page you can find the example usage for javax.swing JRadioButtonMenuItem JRadioButtonMenuItem.

Prototype

public JRadioButtonMenuItem(Action a) 

Source Link

Document

Creates a radio button menu item whose properties are taken from the Action supplied.

Usage

From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java

public static void addProcessorMenu(JMenuBar menuBar) {

    // Create a menu
    JMenu menu = new JMenu("Processing");
    menuBar.add(menu);//from  w w  w.ja va 2  s .c  om

    ButtonGroup itemGroup = new ButtonGroup();

    // Create none item
    JMenuItem noneItem = new JRadioButtonMenuItem("None");
    noneItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("Disables post processing.");
            postProcessorStrategy = null;
        }
    });
    itemGroup.add(noneItem);
    menu.add(noneItem);

    // Create a clustering item
    JMenuItem clusteringInteractorItem = new JRadioButtonMenuItem("Clustering interactor pairs");
    clusteringInteractorItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("Enables post processing: ClusterPerInteractorProcessor");
            postProcessorStrategy = new ClusterInteractorPairProcessor();
        }
    });
    itemGroup.add(clusteringInteractorItem);
    clusteringInteractorItem.setSelected(true);
    menu.add(clusteringInteractorItem);
}

From source file:ru.apertum.qsystem.client.forms.FReception.java

/**
 * Creates new form FReception/*w  w  w. j  a v  a2 s  . c  om*/
 *
 * @param netProperty
 */
public FReception(IClientNetProperty netProperty) {
    this.netProperty = netProperty;
    initComponents();

    setTitle(getTitle() + " " + Uses.getLocaleMessage("project.name" + FAbout.getCMRC_SUFF())); //NOI18N

    try {
        setIconImage(ImageIO
                .read(FAdmin.class.getResource("/ru/apertum/qsystem/client/forms/resources/monitor.png"))); //NOI18N
    } catch (IOException ex) {
        System.err.println(ex);
    }

    // .   Escape  
    // ?  esc
    getRootPane().registerKeyboardAction((ActionEvent e) -> {
        setVisible(false);
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);

    //  trayIcon, .. setSituation()   ? tray
    final JFrame fr = this;
    tray = QTray.getInstance(fr, "/ru/apertum/qsystem/client/forms/resources/monitor.png", getTitle()); //NOI18N
    tray.addItem(getLocaleMessage("messages.tray.showClient"), (ActionEvent e) -> {
        setVisible(true);
        setState(JFrame.NORMAL);
    });
    tray.addItem("-", (ActionEvent e) -> {
    });
    tray.addItem(getLocaleMessage("messages.tray.close"), (ActionEvent e) -> {
        dispose();
        System.exit(0);
    });

    int ii = 1;
    final ButtonGroup bg = new ButtonGroup();
    final String currLng = Locales.getInstance().getLangCurrName();
    for (String lng : Locales.getInstance().getAvailableLocales()) {
        final JRadioButtonMenuItem item = new JRadioButtonMenuItem(
                org.jdesktop.application.Application.getInstance(ru.apertum.qsystem.QSystem.class).getContext()
                        .getActionMap(FReception.class, fr).get("setCurrentLang")); //NOI18N
        bg.add(item);
        item.setSelected(lng.equals(currLng));
        item.setText(lng); // NOI18N
        item.setName("QRadioButtonMenuItem" + (ii++)); // NOI18N
        menuLangs.add(item);
    }

    treeServices.addTreeSelectionListener((TreeSelectionEvent e) -> {
        serviceListChange();
    });

    //  ??    ??.
    listUsers.addListSelectionListener((ListSelectionEvent e) -> {
        userListChange();
    });
}

From source file:unikn.dbis.univis.explorer.VExplorer.java

License:asdf

private void initMenuBar() {

    JMenuBar menuBar = new JMenuBar();

    VMenu program = new VMenu(Constants.PROGRAM);

    VMenuItem schemaImport = new VMenuItem(Constants.SCHEMA_IMPORT, VIcons.SCHEMA_IMPORT);
    schemaImport.setAccelerator(KeyStroke.getKeyStroke('I', Event.CTRL_MASK));
    schemaImport.addActionListener(new ActionListener() {
        /**/*from  www  .j a  v  a2  s . com*/
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();

            fileChooser.addChoosableFileFilter(new FileFilter() {

                /**
                 * Whether the given file is accepted by this filter.
                 */
                public boolean accept(File f) {
                    return f.getName().endsWith(".vs.xml") || f.isDirectory();
                }

                /**
                 * The description of this filter. For example: "JPG and GIF Images"
                 *
                 * @see javax.swing.filechooser.FileView#getName
                 */
                public String getDescription() {
                    return "UniVis Schema (*.vs.xml)";
                }
            });

            int option = fileChooser.showOpenDialog(VExplorer.this);

            if (option == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                new SchemaImport(file);
                refreshTree();
                JOptionPane.showMessageDialog(VExplorer.this, "Schema Import erfolgreich beendet.",
                        "Schema Import", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    program.add(schemaImport);
    program.addSeparator();

    VMenuItem exit = new VMenuItem(Constants.EXIT, VIcons.EXIT);
    exit.setAccelerator(KeyStroke.getKeyStroke('Q', Event.ALT_MASK));
    exit.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    program.add(exit);

    VMenu lafMenu = new VMenu(Constants.LOOK_AND_FEEL);

    ButtonGroup lafGroup = new ButtonGroup();
    for (final UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
        JRadioButtonMenuItem lafMenuItem = new JRadioButtonMenuItem(laf.getName());

        // Set the current Look And Feel as selected.
        if (UIManager.getLookAndFeel().getName().equals(laf.getName())) {
            lafMenuItem.setSelected(true);
        }

        lafMenuItem.addActionListener(new ActionListener() {
            /**
             * Invoked when an action occurs.
             */
            public void actionPerformed(ActionEvent e) {
                updateLookAndFeel(laf.getClassName());
            }
        });

        lafGroup.add(lafMenuItem);
        lafMenu.add(lafMenuItem);
    }

    JMenu questionMark = new JMenu("?");

    VMenuItem license = new VMenuItem(Constants.LICENSE);
    license.addActionListener(new ActionListener() {

        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            new LicenseDialog(VExplorer.this);
        }
    });
    questionMark.add(license);

    final VMenuItem about = new VMenuItem(Constants.ABOUT, VIcons.INFORMATION);
    about.addActionListener(new ActionListener() {

        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            new AboutPanel(VExplorer.this);
        }
    });
    questionMark.add(about);

    menuBar.add(program);
    menuBar.add(lafMenu);
    menuBar.add(questionMark);

    setJMenuBar(menuBar);
}

From source file:us.daveread.basicquery.BasicQuery.java

/**
 * Language selection menu//from w w  w  .j  a  va2 s .co  m
 * 
 * @return The language selection menu
 */
private JMenu languageMenu() {
    JMenu subMenu;
    ButtonGroup buttonGroup;

    // Setup | Language
    subMenu = new JMenu(Resources.getString("mnuSetupLanguageLabel"));
    subMenu.setMnemonic(Resources.getChar("mnuSetupLanguageAccel"));
    subMenu.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuSetupLanguageDesc"));

    // Setup | Language | System Default
    if (System.getProperty(PROP_SYSTEM_DEFAULTLANGUAGE) != null) {
        if (System.getProperty(PROP_SYSTEM_DEFAULTCOUNTRY) != null) {
            configLanguageDefault = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguageDefaultLabel")
                    + " (" + System.getProperty(PROP_SYSTEM_DEFAULTLANGUAGE) + "_"
                    + System.getProperty(PROP_SYSTEM_DEFAULTCOUNTRY) + ")");
        } else {
            configLanguageDefault = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguageDefaultLabel")
                    + " (" + System.getProperty(PROP_SYSTEM_DEFAULTLANGUAGE) + ")");
        }
    } else {
        configLanguageDefault = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguageDefaultLabel"));
    }
    configLanguageDefault.setMnemonic(Resources.getChar("mnuSetupLanguageDefaultAccel"));
    configLanguageDefault.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupLanguageDefaultDesc"));
    configLanguageDefault.addActionListener(this);
    subMenu.add(configLanguageDefault);

    // Setup | Language | Deutsche (German)
    configLanguageGerman = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguageGermanLabel"));
    configLanguageGerman.setMnemonic(Resources.getChar("mnuSetupLanguageGermanAccel"));
    configLanguageGerman.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupLanguageGermanDesc"));
    configLanguageGerman.addActionListener(this);
    subMenu.add(configLanguageGerman);

    // Setup | Language | English
    configLanguageEnglish = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguageEnglishLabel"));
    configLanguageEnglish.setMnemonic(Resources.getChar("mnuSetupLanguageEnglishAccel"));
    configLanguageEnglish.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupLanguageEnglishDesc"));
    configLanguageEnglish.addActionListener(this);
    subMenu.add(configLanguageEnglish);

    // Setup | Language | Espanola (Spanish)
    configLanguageSpanish = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguageSpanishLabel"));
    configLanguageSpanish.setMnemonic(Resources.getChar("mnuSetupLanguageSpanishAccel"));
    configLanguageSpanish.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupLanguageSpanishDesc"));
    configLanguageSpanish.addActionListener(this);
    subMenu.add(configLanguageSpanish);

    // Setup | Language | Francaise (French)
    configLanguageFrench = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguageFrenchLabel"));
    configLanguageFrench.setMnemonic(Resources.getChar("mnuSetupLanguageFrenchAccel"));
    configLanguageFrench.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupLanguageFrenchDesc"));
    configLanguageFrench.addActionListener(this);
    subMenu.add(configLanguageFrench);

    // Setup | Language | Italiana (Italian)
    configLanguageItalian = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguageItalianLabel"));
    configLanguageItalian.setMnemonic(Resources.getChar("mnuSetupLanguageItalianAccel"));
    configLanguageItalian.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupLanguageItalianDesc"));
    configLanguageItalian.addActionListener(this);
    subMenu.add(configLanguageItalian);

    // Setup | Language | Portugues (Portuguese)
    configLanguagePortuguese = new JRadioButtonMenuItem(Resources.getString("mnuSetupLanguagePortugueseLabel"));
    configLanguagePortuguese.setMnemonic(Resources.getChar("mnuSetupLanguagePortugueseAccel"));
    configLanguagePortuguese.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupLanguagePortugueseDesc"));
    configLanguagePortuguese.addActionListener(this);
    subMenu.add(configLanguagePortuguese);

    buttonGroup = new ButtonGroup();
    buttonGroup.add(configLanguageDefault);
    buttonGroup.add(configLanguageEnglish);
    buttonGroup.add(configLanguageFrench);
    buttonGroup.add(configLanguageGerman);
    buttonGroup.add(configLanguageItalian);
    buttonGroup.add(configLanguagePortuguese);
    buttonGroup.add(configLanguageSpanish);

    return subMenu;
}

From source file:us.daveread.basicquery.BasicQuery.java

/**
 * Configuration menu setup/*from   w  w w . j  a  va  2 s  .  c o m*/
 * 
 * @return The configuration menu
 */
private JMenu configurationMenu() {
    JMenu menu;
    JMenu subMenu;
    ButtonGroup buttonGroup;

    // Configuration Menu
    menu = new JMenu(Resources.getString("mnuSetupLabel"));
    menu.setMnemonic(Resources.getChar("mnuSetupAccel"));
    menu.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuSetupDesc"));

    menu.add(languageMenu());

    // Setup | Font
    configFont = new JMenuItem(Resources.getString("mnuConfigFontLabel"));
    configFont.setMnemonic(Resources.getChar("mnuConfigFontAccel"));
    configFont.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuConfigFontDesc"));
    configFont.addActionListener(this);
    configFont.setEnabled(true);
    menu.add(configFont);

    // Setup | Display DB Server Info
    subMenu = new JMenu(Resources.getString("mnuSetupDBServerLabel"));
    subMenu.setMnemonic(Resources.getChar("mnuSetupDBServerAccel"));
    subMenu.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuSetupDBServerDesc"));
    menu.add(subMenu);

    // Configuration | Display DB Server Info | None
    configDisplayDBServerInfoNone = new JRadioButtonMenuItem(Resources.getString("mnuSetupDBServerNoneLabel"));
    configDisplayDBServerInfoNone.setMnemonic(Resources.getChar("mnuSetupDBServerNoneAccel"));
    configDisplayDBServerInfoNone.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupDBServerNoneDesc"));
    subMenu.add(configDisplayDBServerInfoNone);

    // Configuration | Display DB Server Info | Brief
    configDisplayDBServerInfoShort = new JRadioButtonMenuItem(
            Resources.getString("mnuSetupDBServerBriefLabel"));
    configDisplayDBServerInfoShort.setMnemonic(Resources.getChar("mnuSetupDBServerBriefAccel"));
    configDisplayDBServerInfoShort.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupDBServerBriefDesc"));
    subMenu.add(configDisplayDBServerInfoShort);

    // Configuration | Display DB Server Info | Long
    configDisplayDBServerInfoLong = new JRadioButtonMenuItem(Resources.getString("mnuSetupDBServerLongLabel"));
    configDisplayDBServerInfoLong.setMnemonic(Resources.getChar("mnuSetupDBServerLongAccel"));
    configDisplayDBServerInfoLong.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupDBServerLongDesc"));
    subMenu.add(configDisplayDBServerInfoLong);

    buttonGroup = new ButtonGroup();
    buttonGroup.add(configDisplayDBServerInfoNone);
    buttonGroup.add(configDisplayDBServerInfoLong);
    buttonGroup.add(configDisplayDBServerInfoShort);

    // Default is short display of DB server info
    configDisplayDBServerInfoShort.setSelected(true);

    // Setup | Table Row Coloring
    subMenu = new JMenu(Resources.getString("mnuSetupRowColorLabel"));
    subMenu.setMnemonic(Resources.getChar("mnuSetupRowColorAccel"));
    subMenu.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuSetupRowColorDesc"));
    menu.add(subMenu);

    // Setup | Table Row Coloring | None
    configTableColoringNone = new JRadioButtonMenuItem(Resources.getString("mnuSetupRowColorNoneLabel"));
    configTableColoringNone.setMnemonic(Resources.getChar("mnuSetupRowColorNoneAccel"));
    configTableColoringNone.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupRowColorNoneDesc"));
    configTableColoringNone.addActionListener(this);
    subMenu.add(configTableColoringNone);

    // Setup | Table Row Coloring | Green Bar
    configTableColoringGreenBar = new JRadioButtonMenuItem(
            Resources.getString("mnuSetupRowColorGreenBarLabel"));
    configTableColoringGreenBar.setMnemonic(Resources.getChar("mnuSetupRowColorGreenBarAccel"));
    configTableColoringGreenBar.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupRowColorGreenBarDesc"));
    configTableColoringGreenBar.addActionListener(this);
    subMenu.add(configTableColoringGreenBar);

    // Setup | Table Row Coloring | Yellow Bar
    configTableColoringYellowBar = new JRadioButtonMenuItem(
            Resources.getString("mnuSetupRowColorYellowBarLabel"));
    configTableColoringYellowBar.setMnemonic(Resources.getChar("mnuSetupRowColorYellowBarAccel"));
    configTableColoringYellowBar.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupRowColorYellowBarDesc"));
    configTableColoringYellowBar.addActionListener(this);
    subMenu.add(configTableColoringYellowBar);

    subMenu.addSeparator();

    // Setup | Table Row Coloring | User Defined
    configTableColoringUserDefined = new JRadioButtonMenuItem(
            Resources.getString("mnuSetupRowColorUserDefLabel"));
    configTableColoringUserDefined.setMnemonic(Resources.getChar("mnuSetupRowColorUserDefAccel"));
    configTableColoringUserDefined.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupRowColorUserDefDesc"));
    configTableColoringUserDefined.addActionListener(this);
    subMenu.add(configTableColoringUserDefined);

    buttonGroup = new ButtonGroup();
    buttonGroup.add(configTableColoringNone);
    buttonGroup.add(configTableColoringGreenBar);
    buttonGroup.add(configTableColoringYellowBar);
    buttonGroup.add(configTableColoringUserDefined);

    // Default is no special coloring of data rows
    configTableColoringNone.setSelected(true);

    menu.addSeparator();

    // Configuration | Associate SQL and Connect URL
    configHistoryAssocSQLAndConnect = new JCheckBoxMenuItem(Resources.getString("mnuSetupAssocSQLURLLabel"));
    configHistoryAssocSQLAndConnect.setMnemonic(Resources.getChar("mnuSetupAssocSQLURLAccel"));
    configHistoryAssocSQLAndConnect.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupAssocSQLURLDesc"));
    configHistoryAssocSQLAndConnect.setEnabled(true);
    menu.add(configHistoryAssocSQLAndConnect);

    // Configuration | Parse SQL at Semi-Colons
    configParseSemicolons = new JCheckBoxMenuItem(Resources.getString("mnuSetupParseSQLSemicolonLabel"));
    configParseSemicolons.setMnemonic(Resources.getChar("mnuSetupParseSQLSemicolonAccel"));
    configParseSemicolons.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupParseSQLSemicolonDesc"));
    configParseSemicolons.setEnabled(true);
    menu.add(configParseSemicolons);

    menu.addSeparator();

    // Configuration | Display Column Data Type
    configDisplayColumnDataType = new JCheckBoxMenuItem(Resources.getString("mnuSetupDispColTypeLabel"));
    configDisplayColumnDataType.setMnemonic(Resources.getChar("mnuSetupDispColTypeAccel"));
    configDisplayColumnDataType.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupDispColTypeDesc"));
    configDisplayColumnDataType.setEnabled(true);
    configDisplayColumnDataType.setSelected(false);
    menu.add(configDisplayColumnDataType);

    // Configuration | Display Client Info
    configDisplayClientInfo = new JCheckBoxMenuItem(Resources.getString("mnuSetupClientInfoLabel"));
    configDisplayClientInfo.setMnemonic(Resources.getChar("mnuSetupClientInfoAccel"));
    configDisplayClientInfo.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupClientInfoDesc"));
    configDisplayClientInfo.setEnabled(true);
    configDisplayClientInfo.setSelected(false);
    menu.add(configDisplayClientInfo);

    menu.addSeparator();

    // Configuration | Save Password
    configSavePassword = new JCheckBoxMenuItem(Resources.getString("mnuSetupSavePasswordLabel"));
    configSavePassword.setMnemonic(Resources.getChar("mnuSetupSavePasswordAccel"));
    configSavePassword.getAccessibleContext()
            .setAccessibleDescription(Resources.getString("mnuSetupSavePasswordDesc"));
    configSavePassword.setEnabled(true);
    configSavePassword.setSelected(false);
    menu.add(configSavePassword);

    return menu;
}

From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java

private JMenu createShortMenu() {
    JMenu shortMenu = new JMenu();
    addDarkModeCallback(b -> {//  w  ww.j  a  v  a  2  s  . c o m
        shortMenu.setBackground(b ? OPENBST_BLUE.darker().darker() : OPENBST_BLUE.brighter());
        shortMenu.setForeground(b ? Color.WHITE : OPENBST_BLUE);
    });
    shortMenu.setBackground(OPENBST_BLUE.brighter());
    shortMenu.setForeground(OPENBST_BLUE);
    shortMenu.setText(Lang.get("banner.title"));
    shortMenu.setIcon(new ImageIcon(Icons.getImage("Logo", 16)));
    JMenuItem label = new JMenuItem(Lang.get("menu.title"));
    label.setEnabled(false);
    shortMenu.add(label);
    shortMenu.addSeparator();
    shortMenu.add(
            new JMenuItem(new AbstractAction(Lang.get("menu.open"), new ImageIcon(Icons.getImage("Open", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    openStory(VisualsUtils.askForFile(OpenBSTGUI.this, Lang.get("file.title")));
                }
            }));

    shortMenu.addSeparator();

    shortMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.create"), new ImageIcon(Icons.getImage("Add Property", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    doNewEditor();
                }
            }));

    JMenu additionalMenu = new JMenu(Lang.get("menu.advanced"));
    shortMenu.add(additionalMenu);

    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.package"), new ImageIcon(Icons.getImage("Open Archive", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    new PackageDialog(instance).setVisible(true);
                }
            }));
    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("langcheck"), new ImageIcon(Icons.getImage("LangCheck", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    final Map<String, String> languages = new Gson()
                            .fromJson(new InputStreamReader(
                                    OpenBST.class.getResourceAsStream(
                                            "/utybo/branchingstorytree/swing/lang/langs.json"),
                                    StandardCharsets.UTF_8), new TypeToken<Map<String, String>>() {
                                    }.getType());
                    languages.remove("en");
                    languages.remove("default");
                    JComboBox<String> jcb = new JComboBox<>(new Vector<>(languages.keySet()));
                    JPanel panel = new JPanel();
                    panel.add(new JLabel(Lang.get("langcheck.choose")));
                    panel.add(jcb);
                    int result = JOptionPane.showOptionDialog(OpenBSTGUI.this, panel, Lang.get("langcheck"),
                            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
                    if (result == JOptionPane.OK_OPTION) {
                        Locale selected = new Locale((String) jcb.getSelectedItem());
                        if (!Lang.getMap().keySet().contains(selected)) {
                            try {
                                Lang.loadTranslationsFromFile(selected,
                                        OpenBST.class
                                                .getResourceAsStream("/utybo/branchingstorytree/swing/lang/"
                                                        + languages.get(jcb.getSelectedItem().toString())));
                            } catch (UnrespectedModelException | IOException e1) {
                                LOG.warn("Failed to load translation file", e1);
                            }
                        }
                        ArrayList<String> list = new ArrayList<>();
                        Lang.getLocaleMap(Locale.ENGLISH).forEach((k, v) -> {
                            if (!Lang.getLocaleMap(selected).containsKey(k)) {
                                list.add(k + "\n");
                            }
                        });
                        StringBuilder sb = new StringBuilder();
                        Collections.sort(list);
                        list.forEach(s -> sb.append(s));
                        JDialog dialog = new JDialog(OpenBSTGUI.this, Lang.get("langcheck"));
                        dialog.getContentPane().setLayout(new MigLayout());
                        dialog.getContentPane().add(new JLabel(Lang.get("langcheck.result")),
                                "pushx, growx, wrap");
                        JTextArea area = new JTextArea();
                        area.setLineWrap(true);
                        area.setWrapStyleWord(true);
                        area.setText(sb.toString());
                        area.setEditable(false);
                        area.setBorder(BorderFactory.createLoweredBevelBorder());
                        JScrollPane jsp = new JScrollPane(area);
                        jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                        dialog.getContentPane().add(jsp, "pushx, pushy, growx, growy");
                        dialog.setSize((int) (Icons.getScale() * 300), (int) (Icons.getScale() * 300));
                        dialog.setLocationRelativeTo(OpenBSTGUI.this);
                        dialog.setModalityType(ModalityType.APPLICATION_MODAL);
                        dialog.setVisible(true);
                    }
                }
            }));

    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.debug"), new ImageIcon(Icons.getImage("Code", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    DebugInfo.launch(OpenBSTGUI.this);
                }
            }));

    JMenu includedFiles = new JMenu("Included BST files");

    for (Entry<String, String> entry : OpenBST.getInternalFiles().entrySet()) {
        JMenuItem jmi = new JMenuItem(entry.getKey());
        jmi.addActionListener(ev -> {
            String path = "/bst/" + entry.getValue();
            InputStream is = OpenBSTGUI.class.getResourceAsStream(path);
            ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(OpenBSTGUI.this, "Extracting...",
                    is);
            new Thread(() -> {
                try {
                    File f = File.createTempFile("openbstinternal", ".bsp");
                    FileOutputStream fos = new FileOutputStream(f);
                    IOUtils.copy(pmis, fos);
                    openStory(f);
                } catch (final IOException e) {
                    LOG.error("IOException caught", e);
                    showException(Lang.get("file.error").replace("$e", e.getClass().getSimpleName())
                            .replace("$m", e.getMessage()), e);
                }

            }).start();

        });
        includedFiles.add(jmi);
    }
    additionalMenu.add(includedFiles);

    shortMenu.addSeparator();

    JMenu themesMenu = new JMenu(Lang.get("menu.themes"));
    shortMenu.add(themesMenu);
    themesMenu.setIcon(new ImageIcon(Icons.getImage("Color Wheel", 16)));
    ButtonGroup themesGroup = new ButtonGroup();
    JRadioButtonMenuItem jrbmi;

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.dark"));
    if (0 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(0, DARK_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.light"));
    if (1 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(1, LIGHT_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.debug"));
    if (2 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(2, DEBUG_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    JMenu additionalLightThemesMenu = new JMenu(Lang.get("menu.themes.morelight"));
    int j = 3;
    for (Map.Entry<String, LookAndFeel> entry : ADDITIONAL_LIGHT_THEMES.entrySet()) {
        int jf = j;
        jrbmi = new JRadioButtonMenuItem(entry.getKey());
        if (j == selectedTheme)
            jrbmi.setSelected(true);
        jrbmi.addActionListener(e -> switchLaF(jf, entry.getValue()));
        additionalLightThemesMenu.add(jrbmi);
        themesGroup.add(jrbmi);
        j++;
    }
    themesMenu.add(additionalLightThemesMenu);

    JMenu additionalDarkThemesMenu = new JMenu(Lang.get("menu.themes.moredark"));
    for (Map.Entry<String, LookAndFeel> entry : ADDITIONAL_DARK_THEMES.entrySet()) {
        int jf = j;
        jrbmi = new JRadioButtonMenuItem(entry.getKey());
        if (j == selectedTheme)
            jrbmi.setSelected(true);
        jrbmi.addActionListener(e -> switchLaF(jf, entry.getValue()));
        additionalDarkThemesMenu.add(jrbmi);
        themesGroup.add(jrbmi);
        j++;
    }
    themesMenu.add(additionalDarkThemesMenu);

    shortMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.about"), new ImageIcon(Icons.getImage("About", 16))) {
                /**
                 *
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    new AboutDialog(instance).setVisible(true);
                }
            }));

    return shortMenu;
}

From source file:xtrememp.XtremeMP.java

protected void createMenuBar() {
    menuBar = new JMenuBar();

    // File Menu// ww  w.j  a va 2  s  . c  o  m
    String fileMenuStr = tr("MainFrame.Menu.File");
    fileMenu = new JMenu(fileMenuStr);
    fileMenu.setMnemonic(fileMenuStr.charAt(0));

    openMenuItem = new JMenuItem(tr("MainFrame.Menu.File.OpenFile"));
    openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
    openMenuItem.setIcon(Utilities.FOLDER_ICON);
    openMenuItem.addActionListener(this);
    fileMenu.add(openMenuItem);

    openURLMenuItem = new JMenuItem(tr("MainFrame.Menu.File.OpenURL"));
    openURLMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK));
    openURLMenuItem.setIcon(Utilities.FOLDER_REMOTE_ICON);
    openURLMenuItem.addActionListener(this);
    fileMenu.add(openURLMenuItem);

    fileMenu.addSeparator();

    openPlaylistMenuItem = new JMenuItem(tr("MainFrame.Menu.File.OpenPlaylist"));
    openPlaylistMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
    openPlaylistMenuItem.setIcon(Utilities.DOCUMENT_OPEN_ICON);
    openPlaylistMenuItem.addActionListener(this);
    fileMenu.add(openPlaylistMenuItem);

    savePlaylistMenuItem = new JMenuItem(tr("MainFrame.Menu.File.SavePlaylist"));
    savePlaylistMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
    savePlaylistMenuItem.setIcon(Utilities.DOCUMENT_SAVE_ICON);
    savePlaylistMenuItem.addActionListener(this);
    fileMenu.add(savePlaylistMenuItem);

    fileMenu.addSeparator();

    preferencesMenuItem = new JMenuItem(tr("MainFrame.Menu.File.Preferences"));
    preferencesMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK));
    preferencesMenuItem.addActionListener(this);
    fileMenu.add(preferencesMenuItem);

    fileMenu.addSeparator();

    exitMenuItem = new JMenuItem(tr("MainFrame.Menu.File.Exit"));
    exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK));
    exitMenuItem.addActionListener(this);
    fileMenu.add(exitMenuItem);

    menuBar.add(fileMenu);

    // Player Menu
    String playerMenuStr = tr("MainFrame.Menu.Player");
    playerMenu = new JMenu(playerMenuStr);
    playerMenu.setMnemonic(playerMenuStr.charAt(0));

    playPauseMenuItem = new JMenuItem(tr("MainFrame.Menu.Player.Play"));
    playPauseMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK));
    playPauseMenuItem.addActionListener(this);
    playerMenu.add(playPauseMenuItem);

    stopMenuItem = new JMenuItem(tr("MainFrame.Menu.Player.Stop"));
    stopMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_DOWN_MASK));
    //        stopMenuItem.setIcon(Utilities.MEDIA_STOP_ICON);
    stopMenuItem.setEnabled(false);
    stopMenuItem.addActionListener(this);
    playerMenu.add(stopMenuItem);

    previousMenuItem = new JMenuItem(tr("MainFrame.Menu.Player.Previous"));
    previousMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK));
    //        previousMenuItem.setIcon(Utilities.MEDIA_PREVIOUS_ICON);
    previousMenuItem.setEnabled(false);
    previousMenuItem.addActionListener(this);
    playerMenu.add(previousMenuItem);

    nextMenuItem = new JMenuItem(tr("MainFrame.Menu.Player.Next"));
    nextMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
    //        nextMenuItem.setIcon(Utilities.MEDIA_NEXT_ICON);
    nextMenuItem.setEnabled(false);
    nextMenuItem.addActionListener(this);
    playerMenu.add(nextMenuItem);

    playerMenu.addSeparator();

    //PlayMode submenu
    String playModeSubMenuStr = tr("MainFrame.Menu.Player.PlayMode");
    playModeSubMenu = new JMenu(playModeSubMenuStr);

    playModeRepeatNoneMenuItem = new JRadioButtonMenuItem(tr("MainFrame.Menu.Player.PlayMode.RepeatNone"));
    playModeRepeatNoneMenuItem.setIcon(Utilities.PLAYLIST_REPEAT_NONE_ICON);
    playModeRepeatNoneMenuItem.addActionListener(this);
    playModeSubMenu.add(playModeRepeatNoneMenuItem);
    playModeRepeatOneMenuItem = new JRadioButtonMenuItem(tr("MainFrame.Menu.Player.PlayMode.RepeatOne"));
    playModeRepeatOneMenuItem.setIcon(Utilities.PLAYLIST_REPEAT_ONE_ICON);
    playModeRepeatOneMenuItem.addActionListener(this);
    playModeSubMenu.add(playModeRepeatOneMenuItem);
    playModeRepeatAllMenuItem = new JRadioButtonMenuItem(tr("MainFrame.Menu.Player.PlayMode.RepeatAll"));
    playModeRepeatAllMenuItem.setIcon(Utilities.PLAYLIST_REPEAT_ALL_ICON);
    playModeRepeatAllMenuItem.addActionListener(this);
    playModeSubMenu.add(playModeRepeatAllMenuItem);
    playModeShuffleMenuItem = new JRadioButtonMenuItem(tr("MainFrame.Menu.Player.PlayMode.Shuffle"));
    playModeShuffleMenuItem.setIcon(Utilities.PLAYLIST_SHUFFLE_ICON);
    playModeShuffleMenuItem.addActionListener(this);
    playModeSubMenu.add(playModeShuffleMenuItem);

    ButtonGroup playModeBG = new ButtonGroup();
    playModeBG.add(playModeRepeatNoneMenuItem);
    playModeBG.add(playModeRepeatOneMenuItem);
    playModeBG.add(playModeRepeatAllMenuItem);
    playModeBG.add(playModeShuffleMenuItem);

    playerMenu.add(playModeSubMenu);
    playerMenu.addSeparator();

    randomizePlaylistMenuItem = new JMenuItem(tr("MainFrame.Menu.Player.Randomize"));
    randomizePlaylistMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK));
    randomizePlaylistMenuItem.setEnabled(false);
    randomizePlaylistMenuItem.addActionListener(this);
    playerMenu.add(randomizePlaylistMenuItem);

    menuBar.add(playerMenu);

    // View Menu
    String viewMenuStr = tr("MainFrame.Menu.View");
    viewMenu = new JMenu(viewMenuStr);
    viewMenu.setMnemonic(viewMenuStr.charAt(0));

    playlistManagerMenuItem = new JRadioButtonMenuItem(tr("MainFrame.Menu.View.PlaylistManager"));
    playlistManagerMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
    playlistManagerMenuItem.addActionListener(this);
    viewMenu.add(playlistManagerMenuItem);

    visualizationMenuItem = new JRadioButtonMenuItem(tr("MainFrame.Menu.View.Visualizations"));
    visualizationMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.CTRL_DOWN_MASK));
    visualizationMenuItem.addActionListener(this);
    viewMenu.add(visualizationMenuItem);

    ButtonGroup viewBG = new ButtonGroup();
    viewBG.add(playlistManagerMenuItem);
    viewBG.add(visualizationMenuItem);

    menuBar.add(viewMenu);

    // Help menu
    String helpMenuStr = tr("MainFrame.Menu.Help");
    helpMenu = new JMenu(helpMenuStr);
    helpMenu.setMnemonic(helpMenuStr.charAt(0));

    updateMenuItem = new JMenuItem(tr("MainFrame.Menu.Help.CheckForUpdates"));
    updateMenuItem.addActionListener(this);
    helpMenu.add(updateMenuItem);
    helpMenu.addSeparator();

    aboutMenuItem = new JMenuItem(tr("MainFrame.Menu.Help.About"));
    aboutMenuItem.addActionListener(this);
    helpMenu.add(aboutMenuItem);

    menuBar.add(helpMenu);

    menuBar.add(Box.createHorizontalGlue());
    busyLabel = new BusyLabel(new Dimension(20, 20));
    menuBar.add(busyLabel);
    menuBar.add(Box.createHorizontalStrut(8));

    mainFrame.setJMenuBar(menuBar);
}