Example usage for javax.swing JRadioButtonMenuItem getText

List of usage examples for javax.swing JRadioButtonMenuItem getText

Introduction

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

Prototype

public String getText() 

Source Link

Document

Returns the button's text.

Usage

From source file:com.mightypocket.ashot.Mediator.java

void addDevice(final String deviceStr) {
    if (!devices.containsKey(deviceStr)) {
        try {//from  w  w  w . j  a v a  2s .  c  o m
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    JRadioButtonMenuItem item = new JRadioButtonMenuItem(deviceStr);
                    item.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            JRadioButtonMenuItem source = (JRadioButtonMenuItem) e.getSource();
                            String device = source.getText();
                            demon.connectTo(device);
                        }
                    });
                    devicesGroup.add(item);
                    devices.put(deviceStr, item);
                    menuFileDevices.add(item);
                    pcs.firePropertyChange(PROP_DEVICES, null, null);
                }
            });
        } catch (Exception ignore) {
        }
    }
}

From source file:com.mightypocket.ashot.Mediator.java

void removeDevice(final String deviceStr) {
    if (devices.containsKey(deviceStr)) {
        try {/*  w  ww.j a v a  2 s  .  c  om*/
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    JRadioButtonMenuItem item = devices.get(deviceStr);
                    devicesGroup.remove(item);
                    devices.remove(item.getText());
                    menuFileDevices.remove(item);
                    pcs.firePropertyChange(PROP_DEVICES, null, null);
                }
            });
        } catch (Exception ignore) {
        }
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

public void reloadAfterDownloadFromCloud(JStockOptions newJStockOptions) {
    final String oldLookNFeel = this.jStockOptions.getLooknFeel();

    assert (newJStockOptions != null);

    this.jStockOptions.insensitiveCopy(newJStockOptions);

    final String newLookNFeel = this.jStockOptions.getLooknFeel();

    if (oldLookNFeel != null) {
        if (false == oldLookNFeel.equals(newLookNFeel)) {
            this.setLookAndFeel(newLookNFeel);
        }//from  www .j av  a  2  s  .  c o  m
    } else {
        if (null != newLookNFeel) {
            this.setLookAndFeel(newLookNFeel);
        }
    }

    Utils.updateFactoriesPriceSource();

    jStockOptions.setCountry(this.getBestCountryAfterDownloadFromCloud());

    /* These codes are very similar to clean up code during changing country.
     */
    JStock.this.statusBar.setCountryIcon(jStockOptions.getCountry().icon,
            jStockOptions.getCountry().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();

    // Need to read user-defined-database.xml.
    // The user-defined-database.xml is extracted from cloud
    // freshly.
    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();
    this.initAlwaysOnTop();

    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().humanString)) {
            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.JStock.java

private void changeCountry(Country country) {
    if (country == null) {
        return;// ww w.j  a  v  a  2 s  .c  o 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 reloadAfterDownloadFromCloud() {
    /* These codes are very similar to clean up code during changing country.
     *//*from  w  ww . ja v  a2 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;/*from  w ww . j  a  v  a2 s . c om*/
    }

    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;
        }
    }
}