Example usage for javax.swing JCheckBoxMenuItem setText

List of usage examples for javax.swing JCheckBoxMenuItem setText

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.")
public void setText(String text) 

Source Link

Document

Sets the button's text.

Usage

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

/**
 * Build menu items for TA./*  ww w. j  ava2s.  c  o  m*/
 */
private void buildTAMenuItems() {
    final int[] days = { 14, 28, 50, 100, 200 };
    final MACD.Period[] macd_periods = { MACD.Period.newInstance(12, 26, 9) };

    // day_keys, week_keys and month_keys should be having same length as
    // days.        
    final String[] day_keys = { "ChartJDialog_14Days", "ChartJDialog_28Days", "ChartJDialog_50Days",
            "ChartJDialog_100Days", "ChartJDialog_200Days" };
    final String[] week_keys = { "ChartJDialog_14Weeks", "ChartJDialog_28Weeks", "ChartJDialog_50Weeks",
            "ChartJDialog_100Weeks", "ChartJDialog_200Weeks" };
    final String[] month_keys = { "ChartJDialog_14Months", "ChartJDialog_28Months", "ChartJDialog_50Months",
            "ChartJDialog_100Months", "ChartJDialog_200Months" };
    assert (days.length == day_keys.length);
    assert (days.length == week_keys.length);
    assert (days.length == week_keys.length);
    // macd_day_keys, macd_week_keys and macd_month_keys should be having 
    // same length as macd_periods.
    final String[] macd_day_keys = { "ChartJDialog_12_26_9Days" };
    final String[] macd_week_keys = { "ChartJDialog_12_26_9Weeks" };
    final String[] macd_month_keys = { "ChartJDialog_12_26_9Months" };
    assert (macd_periods.length == macd_day_keys.length);
    assert (macd_periods.length == macd_week_keys.length);
    assert (macd_periods.length == macd_month_keys.length);

    String[] keys = null;
    String[] macd_keys = null;
    if (this.getCurrentInterval() == Interval.Daily) {
        keys = day_keys;
        macd_keys = macd_day_keys;
    } else if (this.getCurrentInterval() == Interval.Weekly) {
        keys = week_keys;
        macd_keys = macd_week_keys;
    } else if (this.getCurrentInterval() == Interval.Monthly) {
        keys = month_keys;
        macd_keys = macd_month_keys;
    } else {
        assert (false);
    }
    final TA[] tas = TA.values();
    final String[] ta_keys = { "ChartJDialog_SMA", "ChartJDialog_EMA", "ChartJDialog_MACD", "ChartJDialog_RSI",
            "ChartJDialog_MFI", "ChartJDialog_CCI" };
    final String[] ta_tip_keys = { "ChartJDialog_SimpleMovingAverage", "ChartJDialog_ExponentialMovingAverage",
            "ChartJDialog_MovingAverageConvergenceDivergence", "ChartJDialog_RelativeStrengthIndex",
            "ChartJDialog_MoneyFlowIndex", "ChartJDialog_CommodityChannelIndex" };
    final String[] custom_message_keys = { "info_message_please_enter_number_of_days_for_SMA",
            "info_message_please_enter_number_of_days_for_EMA", "dummy",
            "info_message_please_enter_number_of_days_for_RSI",
            "info_message_please_enter_number_of_days_for_MFI",
            "info_message_please_enter_number_of_days_for_CCI" };
    final Map<TA, Set<Object>> m = new EnumMap<TA, Set<Object>>(TA.class);
    final int taExSize = JStock.instance().getChartJDialogOptions().getTAExSize();
    for (int i = 0; i < taExSize; i++) {
        final TAEx taEx = JStock.instance().getChartJDialogOptions().getTAEx(i);
        if (m.containsKey(taEx.getTA()) == false) {
            m.put(taEx.getTA(), new HashSet<Object>());
        }
        m.get(taEx.getTA()).add(taEx.getParameter());
    }

    for (int i = 0, length = tas.length; i < length; i++) {
        final TA ta = tas[i];
        javax.swing.JMenu menu = new javax.swing.JMenu();
        menu.setText(GUIBundle.getString(ta_keys[i])); // NOI18N
        menu.setToolTipText(GUIBundle.getString(ta_tip_keys[i])); // NOI18N

        if (ta == TA.MACD) {
            for (int j = 0, length2 = macd_periods.length; j < length2; j++) {
                final int _j = j;
                final javax.swing.JCheckBoxMenuItem item = new javax.swing.JCheckBoxMenuItem();
                item.setText(GUIBundle.getString(macd_keys[j]));
                if (m.containsKey(ta)) {
                    if (m.get(ta).contains(macd_periods[_j])) {
                        item.setSelected(true);
                    }
                }
                item.addActionListener(new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        if (ta == TA.MACD) {
                            updateMACD(macd_periods[_j], item.isSelected());
                        }
                    }
                });
                menu.add(item);
            }
        } else {
            for (int j = 0, length2 = days.length; j < length2; j++) {
                final int _j = j;
                final javax.swing.JCheckBoxMenuItem item = new javax.swing.JCheckBoxMenuItem();
                item.setText(GUIBundle.getString(keys[j])); // NOI18N
                if (m.containsKey(ta)) {
                    if (m.get(ta).contains(days[_j])) {
                        item.setSelected(true);
                    }
                }
                item.addActionListener(new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        if (ta == TA.SMA) {
                            updateSMA(days[_j], item.isSelected());
                        } else if (ta == TA.EMA) {
                            updateEMA(days[_j], item.isSelected());
                        } else if (ta == TA.MFI) {
                            updateMFI(days[_j], item.isSelected());
                        } else if (ta == TA.RSI) {
                            updateRSI(days[_j], item.isSelected());
                        } else if (ta == TA.CCI) {
                            updateCCI(days[_j], item.isSelected());
                        }
                    }
                });
                menu.add(item);
            } // for
        } // if (ta == TA.MACD)

        menu.add(new javax.swing.JSeparator());
        javax.swing.JMenuItem item = new javax.swing.JMenuItem();
        item.setText(GUIBundle.getString("ChartJDialog_Custom...")); // NOI18N
        final int _i = i;
        item.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                if (ta == TA.MACD) {
                    showMACDCustomDialog();
                } else {
                    do {
                        final String days_string = JOptionPane.showInputDialog(ChartJDialog.this,
                                MessagesBundle.getString(custom_message_keys[_i]));
                        if (days_string == null) {
                            return;
                        }
                        try {
                            final int days = Integer.parseInt(days_string);
                            if (days <= 0) {
                                JOptionPane.showMessageDialog(ChartJDialog.this,
                                        MessagesBundle.getString("info_message_number_of_days_required"),
                                        MessagesBundle.getString("info_title_number_of_days_required"),
                                        JOptionPane.WARNING_MESSAGE);
                                continue;
                            }
                            ChartJDialog.this.updateTA(ta, days, true);
                            return;
                        } catch (java.lang.NumberFormatException exp) {
                            log.error(null, exp);
                            JOptionPane.showMessageDialog(ChartJDialog.this,
                                    MessagesBundle.getString("info_message_number_of_days_required"),
                                    MessagesBundle.getString("info_title_number_of_days_required"),
                                    JOptionPane.WARNING_MESSAGE);
                            continue;
                        }
                    } while (true);
                }
            }
        });
        menu.add(item);

        // TEMP DISABLE MACD
        // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        if (ta != TA.MACD) {
            this.jMenu2.add(menu);
        }
    } // for
    this.jMenu2.add(new javax.swing.JSeparator());
    javax.swing.JMenuItem item = new javax.swing.JMenuItem();
    item.setText(GUIBundle.getString("ChartJDialog_ClearAll")); // NOI18N
    item.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ChartJDialog.this.clearAll();
        }
    });
    this.jMenu2.add(item);
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private JMenuItem createUseKeywordAutoComplete() {

    JCheckBoxMenuItem menuItem = MenuItemFactory.createCheckBoxMenuItem(action());
    menuItem.setText("Auto-complete keywords");
    menuItem.setSelected(SystemProperties.getBooleanProperty(Constants.USER_PROPERTIES_KEY,
            "editor.autocomplete.keywords.on"));
    menuItem.setActionCommand("updateAutoCompleteKeywordUsage");
    executeActionButtons().add(menuItem);
    return menuItem;
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private JMenuItem createUseSchemaAutoComplete() {

    JCheckBoxMenuItem menuItem = MenuItemFactory.createCheckBoxMenuItem(action());
    menuItem.setText("Auto-complete database objects");
    menuItem.setSelected(SystemProperties.getBooleanProperty(Constants.USER_PROPERTIES_KEY,
            "editor.autocomplete.schema.on"));
    menuItem.setActionCommand("updateAutoCompleteSchemaUsage");
    executeActionButtons().add(menuItem);
    return menuItem;
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private JMenuItem createRecycleResultSetTabMenuItem() {
    JCheckBoxMenuItem menuItem = MenuItemFactory.createCheckBoxMenuItem(action());
    menuItem.setText("Use single resut set tab");
    menuItem.setSelected(UserPreferencesManager.isResultSetTabSingle());
    menuItem.setActionCommand("recycleResultSetTabs");
    executeActionButtons().add(menuItem);
    return menuItem;
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private JMenuItem createShowHideToolsPanelMenuItem() {
    JCheckBoxMenuItem menuItem = MenuItemFactory.createCheckBoxMenuItem(action());
    menuItem.setText("Display tools panel");
    menuItem.setSelected(//from   w ww  . j  a  v a2  s.co m
            SystemProperties.getBooleanProperty(Constants.USER_PROPERTIES_KEY, "editor.display.toolsPanel"));
    menuItem.setActionCommand("toggleToolsPanelVisible");
    executeActionButtons().add(menuItem);
    return menuItem;
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private JMenuItem createShowRowNumberHeaderMenuItem() {
    JCheckBoxMenuItem menuItem = MenuItemFactory.createCheckBoxMenuItem(action());
    menuItem.setText("Show row number header ");
    menuItem.setSelected(//from   w  w  w .ja va2  s .c  o  m
            SystemProperties.getBooleanProperty(Constants.USER_PROPERTIES_KEY, "results.table.row.numbers"));
    menuItem.setActionCommand("toggleRowNumbersVisible");
    executeActionButtons().add(menuItem);
    return menuItem;
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private JMenuItem createRemoveCommentsForQueryMenuItem() {
    JCheckBoxMenuItem menuItem = MenuItemFactory.createCheckBoxMenuItem(action());
    menuItem.setText("Remove comments for execution");
    menuItem.setSelected(SystemProperties.getBooleanProperty(Constants.USER_PROPERTIES_KEY,
            "editor.execute.remove.comments"));
    menuItem.setActionCommand("removeCommentsPriorToQueryExecution");
    executeActionButtons().add(menuItem);
    return menuItem;
}

From source file:org.gtdfree.GTDFree.java

/**
 * This method initializes jMenu   /*from   ww  w . ja v a2 s . c  o m*/
 *    
 * @return javax.swing.JMenu   
 */
private JMenu getHelpMenu() {
    if (helpMenu == null) {
        helpMenu = new JMenu();
        helpMenu.setText(Messages.getString("GTDFree.Help")); //$NON-NLS-1$

        JMenuItem jmi = new JMenuItem(Messages.getString("GTDFree.Help.Home")); //$NON-NLS-1$
        jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser));
        jmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                URI uri;
                try {
                    uri = new URI(getEngine().getConfiguration().getProperty("home.url", //$NON-NLS-1$
                            "http://gtd-free.sourceforge.net")); //$NON-NLS-1$
                    Desktop.getDesktop().browse(uri);
                } catch (Exception e1) {
                    Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$
                }
            }
        });
        helpMenu.add(jmi);

        jmi = new JMenuItem(Messages.getString("GTDFree.Help.Manuals")); //$NON-NLS-1$
        jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser));
        jmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                URI uri;
                try {
                    uri = new URI(getEngine().getConfiguration().getProperty("manuals.url", //$NON-NLS-1$
                            "http://gtd-free.sourceforge.net/manuals.html")); //$NON-NLS-1$ //$NON-NLS-3$
                    Desktop.getDesktop().browse(uri);
                } catch (Exception e1) {
                    Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$
                }
            }
        });
        helpMenu.add(jmi);

        jmi = new JMenuItem(getActionMap().get("importDialog")); //$NON-NLS-1$
        helpMenu.add(jmi);

        helpMenu.add(new JSeparator());

        jmi = new JMenuItem();
        jmi.setText(Messages.getString("GTDFree.Check")); //$NON-NLS-1$
        jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_update));
        jmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                new Thread() {
                    @Override
                    public void run() {
                        checkForUpdates(true);
                    }
                }.start();
            }
        });
        helpMenu.add(jmi);

        JCheckBoxMenuItem jcbmi = new JCheckBoxMenuItem();
        jcbmi.setText(Messages.getString("GTDFree.CheckAtStartup")); //$NON-NLS-1$
        try {
            getEngine().getGlobalProperties().connectBooleanProperty(GlobalProperties.CHECK_FOR_UPDATE_AT_START,
                    jcbmi, "selected", "isSelected", "setSelected", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        } catch (Exception e1) {
            logger.debug("Internal error.", e1); //$NON-NLS-1$
        }
        helpMenu.add(jcbmi);

        helpMenu.add(new JSeparator());

        jmi = new JMenuItem();
        jmi.setText(Messages.getString("GTDFree.Help.Mon")); //$NON-NLS-1$
        jmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                getMonitor().getDialog().setVisible(true);
            }
        });
        helpMenu.add(jmi);

        helpMenu.add(new JSeparator());

        helpMenu.add(getAboutMenuItem());
    }
    return helpMenu;
}