List of usage examples for javax.swing JRadioButtonMenuItem setSelected
public void setSelected(boolean b)
From source file:org.yccheok.jstock.gui.JStock.java
private void changeCountry(Country country) { if (country == null) { return;//from w ww .j ava2s. co m } if (jStockOptions.getCountry() == country) { return; } final Country oldCountry = jStockOptions.getCountry(); if (needToSaveUserDefinedDatabase) { // We are having updated user database in memory. // Save it to disk. this.saveUserDefinedDatabaseAsCSV(oldCountry, stockInfoDatabase); } /* Save the GUI look. */ saveGUIOptions(); /* Need to save chart dialog options? */ saveWatchlist(); this.portfolioManagementJPanel.savePortfolio(); // Spain no longer supported. Sad... if (country == Country.Spain) { JOptionPane.showMessageDialog(null, MessagesBundle.getString("info_message_spain_not_supported"), MessagesBundle.getString("info_title_spain_not_supported"), JOptionPane.INFORMATION_MESSAGE); } jStockOptions.setCountry(country); jStockOptions.addRecentCountry(country); JStock.this.statusBar.setCountryIcon(country.icon, country.humanString); // Here is the dirty trick here. We let our the 'child' panels perform // cleanup/ initialization first before initStockCodeAndSymbolDatabase. // This is because all child panels and stock symbol database task do // interact with status bar. However, We are only most interest in stock symbol // database, as it will be the most busy. Hence, we let the stock symbol // database to be the last, so that its interaction will overwrite the others. this.portfolioManagementJPanel.initPortfolio(); this.indicatorScannerJPanel.stop(); this.indicatorScannerJPanel.clear(); this.initDatabase(true); this.initAjaxProvider(); this.initRealTimeIndexMonitor(); this.initMarketJPanel(); this.initStockHistoryMonitor(); this.initOthersStockHistoryMonitor(); this.initExchangeRateMonitor(); // Initialize real time monitor must come before initialize real time // stocks. We need to submit real time stocks to real time stock monitor. // Hence, after we load real time stocks from file, real time stock monitor // must be ready (initialized). this.initRealTimeStockMonitor(); this.initWatchlist(); this.initAlertStateManager(); this.initDynamicCharts(); // this.initDynamicChartVisibility(); for (Enumeration<AbstractButton> e = this.buttonGroup2.getElements(); e.hasMoreElements();) { AbstractButton button = e.nextElement(); javax.swing.JRadioButtonMenuItem m = (javax.swing.JRadioButtonMenuItem) button; // Ugly fix on spelling mistake. if (country == Country.UnitedState && m.getText().equals(country.toString() + "s")) { m.setSelected(true); break; } if (m.getText().equals(country.toString())) { m.setSelected(true); break; } } }
From source file:org.yccheok.jstock.gui.MainFrame.java
public void setLookAndFeel(String lafClassName) { /* Backward compataible purpose. Old JStockOptions may contain null in this field. */ if (lafClassName == null) { return;// ww w . j a v a 2 s. c o m } try { UIManager.setLookAndFeel(lafClassName); SwingUtilities.updateComponentTreeUI(this); } catch (java.lang.ClassNotFoundException exp) { log.error(null, exp); } catch (java.lang.InstantiationException exp) { log.error(null, exp); } catch (java.lang.IllegalAccessException exp) { log.error(null, exp); } catch (javax.swing.UnsupportedLookAndFeelException exp) { log.error(null, exp); } this.jStockOptions.setLookNFeel(lafClassName); for (Enumeration<AbstractButton> e = this.buttonGroup1.getElements(); e.hasMoreElements();) { AbstractButton button = e.nextElement(); javax.swing.JRadioButtonMenuItem m = (javax.swing.JRadioButtonMenuItem) button; ChangeLookAndFeelAction a = (ChangeLookAndFeelAction) m.getActionListeners()[0]; if (a.getLafClassName().equals(lafClassName)) { m.setSelected(true); break; } } // Sequence are important. The AutoCompleteJComboBox itself should have the highest // priority. ((AutoCompleteJComboBox) jComboBox1).setStockInfoDatabase(this.stockInfoDatabase); this.indicatorPanel.setStockInfoDatabase(this.stockInfoDatabase); }
From source file:org.yccheok.jstock.gui.MainFrame.java
public void reloadAfterDownloadFromCloud() { /* These codes are very similar to clean up code during changing country. *//* w w w .ja v a 2 s . co m*/ MainFrame.this.statusBar.setCountryIcon(jStockOptions.getCountry().getIcon(), jStockOptions.getCountry().toString()); // Here is the dirty trick here. We let our the 'child' panels perform // cleanup/ initialization first before initStockCodeAndSymbolDatabase. // This is because all child panels and stock symbol database task do // interact with status bar. However, We are only most interest in stock symbol // database, as it will be the most busy. Hence, we let the stock symbol // database to be the last, so that its interaction will overwrite the others. this.portfolioManagementJPanel.initPortfolio(); this.indicatorScannerJPanel.stop(); this.indicatorScannerJPanel.clear(); // Need to read user-defined-database.xml. // The user-defined-database.xml is extracted from cloud // freshly. this.initDatabase(true); this.initAjaxProvider(); this.initMarketThread(); this.initMarketJPanel(); this.initStockHistoryMonitor(); this.initOthersStockHistoryMonitor(); this.initCurrencyExchangeMonitor(); // Initialize real time monitor must come before initialize real time // stocks. We need to submit real time stocks to real time stock monitor. // Hence, after we load real time stocks from file, real time stock monitor // must be ready (initialized). this.initRealTimeStockMonitor(); this.initWatchlist(); this.initAlertStateManager(); this.initDynamicCharts(); this.initDynamicChartVisibility(); for (Enumeration<AbstractButton> e = this.buttonGroup2.getElements(); e.hasMoreElements();) { AbstractButton button = e.nextElement(); javax.swing.JRadioButtonMenuItem m = (javax.swing.JRadioButtonMenuItem) button; if (m.getText().equals(jStockOptions.getCountry().toHumanReadableString())) { m.setSelected(true); break; } } if (null != this.indicatorPanel) { this.indicatorPanel.initIndicatorProjectManager(); this.indicatorPanel.initModuleProjectManager(); } // I will try to reload the GUI settings for Stock Watchlist and Stock // Indicator Scanner. I hope that the sudden change in GUI will not give // user a shock. this.initGUIOptions(); this.indicatorScannerJPanel.initGUIOptions(); }
From source file:org.yccheok.jstock.gui.MainFrame.java
private void changeCountry(Country country) { if (country == null) { return;// w ww.java2s .c o m } if (jStockOptions.getCountry() == country) { return; } if (needToSaveUserDefinedDatabase) { // We are having updated user database in memory. // Save it to disk. this.saveUserDefinedDatabaseAsCSV(country, stockInfoDatabase); } /* Save the GUI look. */ saveGUIOptions(); /* Need to save chart dialog options? */ saveWatchlist(); this.portfolioManagementJPanel.savePortfolio(); // Spain no longer supported. Sad... if (country == Country.Spain) { JOptionPane.showMessageDialog(null, MessagesBundle.getString("info_message_spain_not_supported"), MessagesBundle.getString("info_title_spain_not_supported"), JOptionPane.INFORMATION_MESSAGE); } jStockOptions.setCountry(country); MainFrame.this.statusBar.setCountryIcon(country.getIcon(), country.toString()); // Here is the dirty trick here. We let our the 'child' panels perform // cleanup/ initialization first before initStockCodeAndSymbolDatabase. // This is because all child panels and stock symbol database task do // interact with status bar. However, We are only most interest in stock symbol // database, as it will be the most busy. Hence, we let the stock symbol // database to be the last, so that its interaction will overwrite the others. this.portfolioManagementJPanel.initPortfolio(); this.indicatorScannerJPanel.stop(); this.indicatorScannerJPanel.clear(); this.initDatabase(true); this.initAjaxProvider(); this.initMarketThread(); this.initMarketJPanel(); this.initStockHistoryMonitor(); this.initOthersStockHistoryMonitor(); this.initCurrencyExchangeMonitor(); // Initialize real time monitor must come before initialize real time // stocks. We need to submit real time stocks to real time stock monitor. // Hence, after we load real time stocks from file, real time stock monitor // must be ready (initialized). this.initRealTimeStockMonitor(); this.initWatchlist(); this.initAlertStateManager(); this.initDynamicCharts(); // this.initDynamicChartVisibility(); for (Enumeration<AbstractButton> e = this.buttonGroup2.getElements(); e.hasMoreElements();) { AbstractButton button = e.nextElement(); javax.swing.JRadioButtonMenuItem m = (javax.swing.JRadioButtonMenuItem) button; // Ugly fix on spelling mistake. if (country == Country.UnitedState && m.getText().equals(country.toString() + "s")) { m.setSelected(true); break; } if (m.getText().equals(country.toString())) { m.setSelected(true); break; } } }
From source file:richtercloud.document.scanner.gui.OCRPanel.java
/** * Creates new form OCRResultPanel/*from w ww .java2 s .c o m*/ * @param reflectionFormPanelMap A map with references to the * {@link ReflectionFormPanel} for each entity class which is manipulated by * the context menu items */ public OCRPanel(Set<Class<?>> entityClasses, Map<Class<?>, ReflectionFormPanel<?>> reflectionFormPanelMap, Map<Class<? extends JComponent>, ValueSetter<?, ?>> valueSetterMapping, EntityManager entityManager, MessageHandler messageHandler, ReflectionFormBuilder reflectionFormBuilder, DocumentScannerConf documentScannerConf) { this.initComponents(); if (messageHandler == null) { throw new IllegalArgumentException("messageHandler mustn't be null"); } this.messageHandler = messageHandler; if (documentScannerConf == null) { throw new IllegalArgumentException("documentScannerConf mustn't be " + "null"); } this.documentScannerConf = documentScannerConf; List<Class<?>> entityClassesSort = EntityPanel.sortEntityClasses(entityClasses); for (Class<?> entityClass : entityClassesSort) { ReflectionFormPanel<?> reflectionFormPanel = reflectionFormPanelMap.get(entityClass); if (reflectionFormPanel == null) { throw new IllegalArgumentException( String.format("entityClass %s has no %s mapped in reflectionFormPanelMap", entityClass, ReflectionFormPanel.class)); } String className; ClassInfo classInfo = entityClass.getAnnotation(ClassInfo.class); if (classInfo != null) { className = classInfo.name(); } else { className = entityClass.getSimpleName(); } JMenu entityClassMenu = new JMenu(className); List<Field> relevantFields = reflectionFormBuilder.getFieldRetriever() .retrieveRelevantFields(entityClass); for (Field relevantField : relevantFields) { String fieldName; FieldInfo fieldInfo = relevantField.getAnnotation(FieldInfo.class); if (fieldInfo != null) { fieldName = fieldInfo.name(); } else { fieldName = relevantField.getName(); } JMenuItem relevantFieldMenuItem = new JMenuItem(fieldName); relevantFieldMenuItem.addActionListener( new FieldActionListener(reflectionFormPanel, relevantField, valueSetterMapping)); entityClassMenu.add(relevantFieldMenuItem); } this.oCRResultPopupPasteIntoMenu.add(entityClassMenu); } Map<String, Pair<NumberFormat, Set<Locale>>> numberFormats = new HashMap<>(); Map<String, Pair<NumberFormat, Set<Locale>>> percentFormats = new HashMap<>(); Map<String, Pair<NumberFormat, Set<Locale>>> currencyFormats = new HashMap<>(); Iterator<Locale> localeIterator = new ArrayList<>(Arrays.asList(Locale.getAvailableLocales())).iterator(); Locale firstLocale = localeIterator.next(); String numberString = NumberFormat.getNumberInstance(firstLocale).format(FORMAT_VALUE); String percentString = NumberFormat.getPercentInstance(firstLocale).format(FORMAT_VALUE); String currencyString = NumberFormat.getCurrencyInstance(firstLocale).format(FORMAT_VALUE); numberFormats.put(numberString, new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getNumberInstance(firstLocale), new HashSet<>(Arrays.asList(firstLocale)))); percentFormats.put(percentString, new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getPercentInstance(firstLocale), new HashSet<>(Arrays.asList(firstLocale)))); currencyFormats.put(currencyString, new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getCurrencyInstance(firstLocale), new HashSet<>(Arrays.asList(firstLocale)))); while (localeIterator.hasNext()) { Locale locale = localeIterator.next(); numberString = NumberFormat.getNumberInstance(locale).format(FORMAT_VALUE); percentString = NumberFormat.getPercentInstance(locale).format(FORMAT_VALUE); currencyString = NumberFormat.getCurrencyInstance(locale).format(FORMAT_VALUE); Pair<NumberFormat, Set<Locale>> numberFormatsPair = numberFormats.get(numberString); if (numberFormatsPair == null) { numberFormatsPair = new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getNumberInstance(locale), new HashSet<Locale>()); numberFormats.put(numberString, numberFormatsPair); } Set<Locale> numberFormatsLocales = numberFormatsPair.getValue(); numberFormatsLocales.add(locale); Pair<NumberFormat, Set<Locale>> percentFormatsPair = percentFormats.get(percentString); if (percentFormatsPair == null) { percentFormatsPair = new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getPercentInstance(locale), new HashSet<Locale>()); percentFormats.put(percentString, percentFormatsPair); } Set<Locale> percentFormatsLocales = percentFormatsPair.getValue(); percentFormatsLocales.add(locale); Pair<NumberFormat, Set<Locale>> currencyFormatsPair = currencyFormats.get(currencyString); if (currencyFormatsPair == null) { currencyFormatsPair = new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getCurrencyInstance(locale), new HashSet<Locale>()); currencyFormats.put(currencyString, currencyFormatsPair); } Set<Locale> currencyFormatsLocales = currencyFormatsPair.getValue(); currencyFormatsLocales.add(locale); } for (Map.Entry<String, Pair<NumberFormat, Set<Locale>>> numberFormat : numberFormats.entrySet()) { JRadioButtonMenuItem menuItem = new NumberFormatMenuItem(numberFormat.getValue().getKey()); numberFormatPopup.add(menuItem); numberFormatPopupButtonGroup.add(menuItem); if (numberFormat.getValue().getValue().contains(this.documentScannerConf.getLocale())) { menuItem.setSelected(true); } } for (Map.Entry<String, Pair<NumberFormat, Set<Locale>>> percentFormat : percentFormats.entrySet()) { JRadioButtonMenuItem menuItem = new NumberFormatMenuItem(percentFormat.getValue().getKey()); percentFormatPopup.add(menuItem); percentFormatPopupButtonGroup.add(menuItem); if (percentFormat.getValue().getValue().contains(this.documentScannerConf.getLocale())) { menuItem.setSelected(true); } } for (Map.Entry<String, Pair<NumberFormat, Set<Locale>>> currencyFormat : currencyFormats.entrySet()) { JRadioButtonMenuItem menuItem = new NumberFormatMenuItem(currencyFormat.getValue().getKey()); currencyFormatPopup.add(menuItem); currencyFormatPopupButtonGroup.add(menuItem); if (currencyFormat.getValue().getValue().contains(this.documentScannerConf.getLocale())) { menuItem.setSelected(true); } } }
From source file:ru.apertum.qsystem.client.forms.FReception.java
/** * Creates new form FReception// www . java 2 s . c o m * * @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() { /**/* w ww . j a va 2 s .c o m*/ * 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:utybo.branchingstorytree.swing.OpenBSTGUI.java
private JMenu createShortMenu() { JMenu shortMenu = new JMenu(); addDarkModeCallback(b -> {/*from ww w . 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; }