List of usage examples for javax.swing JMenu addSeparator
public void addSeparator()
From source file:us.daveread.basicquery.BasicQuery.java
/** * Configuration menu setup/*www .ja v a2s . com*/ * * @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:us.daveread.basicquery.BasicQuery.java
/** * Help menu setup/* w w w . j a v a 2 s . c om*/ * * @return The help menu */ private JMenu helpMenu() { JMenu menu; // Help Menu menu = new JMenu(Resources.getString("mnuHelpLabel")); menu.setMnemonic(Resources.getChar("mnuHelpAccel")); menu.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuHelpDesc")); // Help | Parameterized SQL Statement helpParameterizedSQL = new JMenuItem(Resources.getString("mnuHelpParamSQLLabel")); helpParameterizedSQL.setMnemonic(Resources.getChar("mnuHelpParamSQLAccel")); helpParameterizedSQL.getAccessibleContext() .setAccessibleDescription(Resources.getString("mnuHelpParamSQLDesc")); helpParameterizedSQL.addActionListener(this); helpParameterizedSQL.setEnabled(true); menu.add(helpParameterizedSQL); menu.addSeparator(); // Help | About helpAbout = new JMenuItem(Resources.getString("mnuHelpAboutLabel")); helpAbout.setMnemonic(Resources.getChar("mnuHelpAboutAccel")); helpAbout.getAccessibleContext().setAccessibleDescription(Resources.getString("mnuHelpAboutDesc")); helpAbout.addActionListener(this); helpAbout.setEnabled(true); menu.add(helpAbout); return menu; }
From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java
private JMenu createShortMenu() { JMenu shortMenu = new JMenu(); addDarkModeCallback(b -> {/*from w w w . j a v a 2s .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:xapps.browser.gsea.GseaFijiTabsApplicationFrame.java
/** * @param name//w w w . j a va 2s .co m * @param objs -> array of Action objects interspersed with nulls wherever * a seperator is needed. * For example new Object[]{Foo, Bar, null, Zoo}; * @return */ private JMenu createJMenu(final String name, final Object[] objs) { JMenu menu = new JMenu(name, true); // true -> can tear off for (int i = 0; i < objs.length; i++) { if (objs[i] == null) { menu.addSeparator(); } else { if (objs[i] instanceof JMenuItem) { menu.add((JMenuItem) objs[i]); } else if (objs[i] instanceof String) { menu.add(objs[i].toString()); } else { menu.add(new JMenuItem((Action) objs[i])); } } } return menu; }