Example usage for javax.swing JMenu setText

List of usage examples for javax.swing JMenu setText

Introduction

In this page you can find the example usage for javax.swing JMenu 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:blue.automation.AutomationManager.java

public JPopupMenu getAutomationMenu(SoundLayer soundLayer) {
    this.selectedSoundLayer = soundLayer;

    // if (menu == null || dirty) {
    JPopupMenu menu = new JPopupMenu();

    // Build Instrument Menu
    JMenu instrRoot = new JMenu("Instrument");

    Arrangement arrangement = data.getArrangement();

    ParameterIdList paramIdList = soundLayer.getAutomationParameters();

    for (int i = 0; i < arrangement.size(); i++) {
        InstrumentAssignment ia = arrangement.getInstrumentAssignment(i);

        if (ia.enabled && ia.instr instanceof Automatable) {

            ParameterList params = ((Automatable) ia.instr).getParameterList();

            if (params.size() <= 0) {
                continue;
            }//  w  w w .  j ava  2 s . c om

            JMenu instrMenu = new JMenu();
            instrMenu.setText(ia.arrangementId + ") " + ia.instr.getName());

            for (int j = 0; j < params.size(); j++) {
                Parameter param = params.getParameter(j);
                JMenuItem paramItem = new JMenuItem();
                paramItem.setText(param.getName());
                paramItem.addActionListener(parameterActionListener);

                if (param.isAutomationEnabled()) {
                    if (paramIdList.contains(param.getUniqueId())) {
                        paramItem.setForeground(Color.GREEN);
                    } else {
                        paramItem.setForeground(Color.ORANGE);
                    }

                }

                paramItem.putClientProperty("instr", ia.instr);
                paramItem.putClientProperty("param", param);

                instrMenu.add(paramItem);
            }
            instrRoot.add(instrMenu);
        }
    }

    menu.add(instrRoot);

    // Build Mixer Menu
    Mixer mixer = data.getMixer();

    if (mixer.isEnabled()) {
        JMenu mixerRoot = new JMenu("Mixer");

        // add channels
        ChannelList channels = mixer.getChannels();

        if (channels.size() > 0) {
            JMenu channelsMenu = new JMenu("Channels");

            for (int i = 0; i < channels.size(); i++) {
                channelsMenu.add(buildChannelMenu(channels.getChannel(i), soundLayer));
            }

            mixerRoot.add(channelsMenu);
        }

        // add subchannels
        ChannelList subChannels = mixer.getSubChannels();

        if (subChannels.size() > 0) {
            JMenu subChannelsMenu = new JMenu("Sub-Channels");
            for (int i = 0; i < subChannels.size(); i++) {
                subChannelsMenu.add(buildChannelMenu(subChannels.getChannel(i), soundLayer));
            }

            mixerRoot.add(subChannelsMenu);
        }

        // add master channel
        Channel master = mixer.getMaster();

        mixerRoot.add(buildChannelMenu(master, soundLayer));

        menu.add(mixerRoot);
    }

    menu.addSeparator();

    JMenuItem clearAll = new JMenuItem("Clear All");
    clearAll.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Object retVal = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(
                    "Please Confirm Clearing All Parameter Data for this SoundLayer"));

            if (retVal == NotifyDescriptor.YES_OPTION) {

                ParameterIdList idList = selectedSoundLayer.getAutomationParameters();

                Iterator iter = new ArrayList(idList.getParameters()).iterator();

                while (iter.hasNext()) {
                    String paramId = (String) iter.next();
                    Parameter param = getParameter(paramId);

                    param.setAutomationEnabled(false);
                    idList.removeParameterId(paramId);
                }
            }
        }
    });
    menu.add(clearAll);

    clearAll.setEnabled(soundLayer.getAutomationParameters().size() > 0);

    // }

    // System.err.println(parameterMap);

    return menu;
}

From source file:org.ash.gui.MainFrame.java

/**
 * Creates the menu bar./*w ww .  ja v a2s.  c om*/
 * 
 * @return the j menu bar
 */
private JMenuBar createMenuBar() {
    JMenu menuFile = new JMenu();

    menuFile.setMnemonic(Options.getInstance().getResource("file.mnemonic").charAt(0));
    menuFile.setText(Options.getInstance().getResource("file.text"));
    menuFileExit.setMnemonic(Options.getInstance().getResource("exit.mnemonic").charAt(0));
    menuFileExit.setText(Options.getInstance().getResource("exit.text"));
    menuFileExit.addActionListener(new MainFrame_menuFileExit_ActionAdapter(this));

    menuFile.add(menuFileExit);

    JMenu menuHelp = new JMenu();
    menuHelp.setMnemonic(Options.getInstance().getResource("help.mnemonic").charAt(0));
    menuHelp.setText(Options.getInstance().getResource("help.text"));
    menuHelpAbout.setMnemonic(Options.getInstance().getResource("about.mnemonic").charAt(0));
    menuHelpAbout.setText(Options.getInstance().getResource("about.text"));
    menuHelpAbout.addActionListener(new MainFrame_menuHelpAbout_ActionAdapter(this));

    menuHelp.add(menuHelpAbout);

    JMenuBar bar = new JMenuBar();

    bar.add(menuFile);
    bar.add(menuHelp);

    return bar;
}

From source file:au.org.ala.delta.editor.DeltaEditor.java

private void buildWindowMenu(JMenu mnuWindow) {
    mnuWindow.removeAll();// w  ww. j  a  v  a  2 s.  c o m

    JMenuItem mnuItCascade = new JMenuItem();
    mnuItCascade.setAction(_actionMap.get("cascadeFrames"));
    mnuWindow.add(mnuItCascade);

    JMenuItem mnuItTile = new JMenuItem();
    mnuItTile.setAction(_actionMap.get("tileFrames"));
    mnuWindow.add(mnuItTile);

    JMenuItem mnuItTileHorz = new JMenuItem();
    mnuItTileHorz.setAction(_actionMap.get("tileFramesHorizontally"));
    mnuWindow.add(mnuItTileHorz);

    JMenuItem mnuItArrangeIcons = new JMenuItem();
    mnuItArrangeIcons.setAction(_actionMap.get("arrangeIcons"));
    mnuWindow.add(mnuItArrangeIcons);

    JMenuItem mnuItCloseAll = new JMenuItem();
    mnuItCloseAll.setAction(_actionMap.get("closeAllFrames"));
    mnuWindow.add(mnuItCloseAll);

    mnuWindow.addSeparator();

    JMenuItem mnuItChooseFont = new JMenuItem();
    mnuItChooseFont.setAction(_actionMap.get("chooseFont"));
    mnuWindow.add(mnuItChooseFont);

    mnuWindow.addSeparator();

    JMenu mnuLF = new JMenu();
    mnuLF.setName("mnuLF");
    mnuLF.setText(_resourceMap.getString("mnuLF.text"));
    mnuWindow.add(mnuLF);

    JMenuItem mnuItMetalLF = new JMenuItem();
    mnuItMetalLF.setAction(_actionMap.get("metalLookAndFeel"));
    mnuLF.add(mnuItMetalLF);

    JMenuItem mnuItWindowsLF = new JMenuItem();
    mnuItWindowsLF.setAction(_actionMap.get("systemLookAndFeel"));
    mnuLF.add(mnuItWindowsLF);

    try {
        // Nimbus L&F was added in update java 6 update 10.
        Class.forName("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel").newInstance();
        JMenuItem mnuItNimbusLF = new JMenuItem();
        mnuItNimbusLF.setAction(_actionMap.get("nimbusLookAndFeel"));
        mnuLF.add(mnuItNimbusLF);
    } catch (Exception e) {
        // The Nimbus L&F is not available, no matter.
    }
    mnuWindow.addSeparator();

    int i = 1;
    for (final JInternalFrame frame : _frames) {
        JMenuItem windowItem = new JCheckBoxMenuItem();
        if (i < 10) {
            windowItem.setText(String.format("%d %s", i, frame.getTitle()));
            windowItem.setMnemonic(KeyEvent.VK_1 + (i - 1));
        } else {
            windowItem.setText(frame.getTitle());
        }
        windowItem.setSelected(frame.isSelected());
        windowItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    frame.setSelected(true);
                } catch (PropertyVetoException e1) {
                }
            }
        });
        mnuWindow.add(windowItem);
        ++i;
    }

}

From source file:ResourceBundleSupport.java

/**
 * Returns a JMenu created from a resource bundle definition.
 * <p/>/*from ww w. j  a v a2  s .  co  m*/
 * The menu definition consists of two keys, the name of the menu and the
 * mnemonic for that menu. Both keys share a common prefix, which is
 * extended by ".name" for the name of the menu and ".mnemonic" for the
 * mnemonic.
 * <p/>
 * <pre>
 * # define the file menu
 * menu.file.name=File
 * menu.file.mnemonic=F
 * </pre>
 * The menu definition above can be used to create the menu by calling
 * <code>createMenu ("menu.file")</code>.
 *
 * @param keyPrefix the common prefix for that menu
 * @return the created menu
 */
public JMenu createMenu(final String keyPrefix) {
    final JMenu retval = new JMenu();
    retval.setText(getString(keyPrefix + ".name"));
    retval.setMnemonic(getMnemonic(keyPrefix + ".mnemonic").intValue());
    return retval;
}

From source file:at.becast.youploader.gui.FrmMain.java

public void initMenuBar() {
    JMenuBar mnuBar = new JMenuBar();
    JMenu mnuFile = new JMenu();
    JMenuItem mnuQuit = new JMenuItem();
    mnuAcc = new JMenu();

    mnuFile.setText(LANG.getString("frmMain.menu.File"));

    mnuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));
    mnuQuit.setText(LANG.getString("frmMain.menu.Quit"));
    mnuQuit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            mnuQuitActionPerformed();//from   w w w. java  2s . com
        }
    });
    mnuFile.add(mnuQuit);

    mnuBar.add(mnuFile);

    mnuAcc.setText(LANG.getString("frmMain.menu.Account"));
    mnuBar.add(mnuAcc);

    JSeparator separator = new JSeparator();
    JMenuItem mntmAddAccount = new JMenuItem(LANG.getString("frmMain.menu.AddAccount"));
    mntmAddAccount.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            mntmAddAccountActionPerformed();
        }
    });
    mnuAcc.add(mntmAddAccount);
    mnuAcc.add(separator);

    JMenu mnLanguage = new JMenu("Language");
    mnLanguage.setVisible(false);
    mnLanguage.setEnabled(false);
    mnuBar.add(mnLanguage);

    JMenu menu = new JMenu("?");
    mnuBar.add(menu);

    JMenuItem mntmDonate = new JMenuItem(LANG.getString("frmMain.menu.Donate"));
    menu.add(mntmDonate);
    mntmDonate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            donateButton();
        }
    });

    JMenuItem mntmAbout = new JMenuItem(LANG.getString("frmMain.menu.About"));
    mntmAbout.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            FrmAbout about = new FrmAbout();
            about.setVisible(true);
        }
    });
    menu.add(mntmAbout);

    JMenuItem mntmShowLogfile = new JMenuItem(LANG.getString("frmMain.menu.ShowLogfile"));
    mntmShowLogfile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader"));
        }
    });
    menu.add(mntmShowLogfile);

    JMenuItem mntmUploadLogfile = new JMenuItem(LANG.getString("frmMain.menu.UploadLatestLogfile"));
    mntmUploadLogfile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader"));
        }
    });
    menu.add(mntmUploadLogfile);

    chckbxmntmCheckForUpdates = new JCheckBoxMenuItem(LANG.getString("frmMain.menu.CheckforUpdates"));
    menu.add(chckbxmntmCheckForUpdates);
    if (Main.s.setting.get("notify_updates").equals("1")) {
        chckbxmntmCheckForUpdates.setSelected(true);
    }
    chckbxmntmCheckForUpdates.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            toggleUpdateNotifier();
        }
    });
    setJMenuBar(mnuBar);
}

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

/**
 * Build menu items for TA./* www.j  av a2 s. c om*/
 */
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:com.maxl.java.amikodesk.AMiKoDesk.java

private static void createAndShowFullGUI() {
    // Create and setup window
    final JFrame jframe = new JFrame(Constants.APP_NAME);
    jframe.setName(Constants.APP_NAME + ".main");

    int min_width = CML_OPT_WIDTH;
    int min_height = CML_OPT_HEIGHT;
    jframe.setPreferredSize(new Dimension(min_width, min_height));
    jframe.setMinimumSize(new Dimension(min_width, min_height));
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - min_width) / 2;
    int y = (screen.height - min_height) / 2;
    jframe.setBounds(x, y, min_width, min_height);

    // Set application icon
    if (Utilities.appCustomization().equals("ywesee")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("desitin")) {
        ImageIcon img = new ImageIcon(Constants.DESITIN_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("meddrugs")) {
        ImageIcon img = new ImageIcon(Constants.MEDDRUGS_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("zurrose")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    }//  w w  w .  j  av a2s.co  m

    // ------ Setup menubar ------
    JMenuBar menu_bar = new JMenuBar();
    // menu_bar.add(Box.createHorizontalGlue()); // --> aligns menu items to the right!
    // -- Menu "Datei" --
    JMenu datei_menu = new JMenu("Datei");
    if (Utilities.appLanguage().equals("fr"))
        datei_menu.setText("Fichier");
    menu_bar.add(datei_menu);
    JMenuItem print_item = new JMenuItem("Drucken...");
    JMenuItem settings_item = new JMenuItem(m_rb.getString("settings") + "...");
    JMenuItem quit_item = new JMenuItem("Beenden");
    if (Utilities.appLanguage().equals("fr")) {
        print_item.setText("Imprimer");
        quit_item.setText("Terminer");
    }
    datei_menu.add(print_item);
    datei_menu.addSeparator();
    datei_menu.add(settings_item);
    datei_menu.addSeparator();
    datei_menu.add(quit_item);

    // -- Menu "Aktualisieren" --
    JMenu update_menu = new JMenu("Aktualisieren");
    if (Utilities.appLanguage().equals("fr"))
        update_menu.setText("Mise  jour");
    menu_bar.add(update_menu);
    final JMenuItem updatedb_item = new JMenuItem("Aktualisieren via Internet...");
    updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    JMenuItem choosedb_item = new JMenuItem("Aktualisieren via Datei...");
    update_menu.add(updatedb_item);
    update_menu.add(choosedb_item);
    if (Utilities.appLanguage().equals("fr")) {
        updatedb_item.setText("Tlcharger la banque de donnes...");
        updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        choosedb_item.setText("Ajourner la banque de donnes...");
    }

    // -- Menu "Hilfe" --
    JMenu hilfe_menu = new JMenu("Hilfe");
    if (Utilities.appLanguage().equals("fr"))
        hilfe_menu.setText("Aide");
    menu_bar.add(hilfe_menu);

    JMenuItem about_item = new JMenuItem("ber " + Constants.APP_NAME + "...");
    JMenuItem ywesee_item = new JMenuItem(Constants.APP_NAME + " im Internet");
    if (Utilities.appCustomization().equals("meddrugs"))
        ywesee_item.setText("med-drugs im Internet");
    JMenuItem report_item = new JMenuItem("Error Report...");
    JMenuItem contact_item = new JMenuItem("Kontakt...");

    if (Utilities.appLanguage().equals("fr")) {
        // Extrawunsch med-drugs
        if (Utilities.appCustomization().equals("meddrugs"))
            about_item.setText(Constants.APP_NAME);
        else
            about_item.setText("A propos de " + Constants.APP_NAME + "...");
        contact_item.setText("Contact...");
        if (Utilities.appCustomization().equals("meddrugs"))
            ywesee_item.setText("med-drugs sur Internet");
        else
            ywesee_item.setText(Constants.APP_NAME + " sur Internet");
        report_item.setText("Rapport d'erreur...");
    }
    hilfe_menu.add(about_item);
    hilfe_menu.add(ywesee_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(report_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(contact_item);

    // Menu "Abonnieren" (only for ywesee)
    JMenu subscribe_menu = new JMenu("Abonnieren");
    if (Utilities.appLanguage().equals("fr"))
        subscribe_menu.setText("Abonnement");
    if (Utilities.appCustomization().equals("ywesee")) {
        menu_bar.add(subscribe_menu);
    }

    jframe.setJMenuBar(menu_bar);

    // ------ Setup toolbar ------
    JToolBar toolBar = new JToolBar("Database");
    toolBar.setPreferredSize(new Dimension(jframe.getWidth(), 64));
    final JToggleButton selectAipsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "aips32x32_bright.png"));
    final JToggleButton selectFavoritesButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "favorites32x32_bright.png"));
    final JToggleButton selectInteractionsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "interactions32x32_bright.png"));
    final JToggleButton selectShoppingCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "shoppingcart32x32_bright.png"));
    final JToggleButton selectComparisonCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "comparisoncart32x32_bright.png"));

    final JToggleButton list_of_buttons[] = { selectAipsButton, selectFavoritesButton, selectInteractionsButton,
            selectShoppingCartButton, selectComparisonCartButton };

    if (Utilities.appLanguage().equals("de")) {
        setupButton(selectAipsButton, "Kompendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favoriten", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interaktionen", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Warenkorb", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    } else if (Utilities.appLanguage().equals("fr")) {
        setupButton(selectAipsButton, "Compendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favorites", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interactions", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Panier", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    }

    // Add to toolbar and set up
    toolBar.setBackground(m_toolbar_bg);
    toolBar.add(selectAipsButton);
    toolBar.addSeparator();
    toolBar.add(selectFavoritesButton);
    toolBar.addSeparator();
    toolBar.add(selectInteractionsButton);
    if (!Utilities.appCustomization().equals("zurrose")) {
        toolBar.addSeparator();
        toolBar.add(selectShoppingCartButton);
    }
    if (Utilities.appCustomization().equals("zurrorse")) {
        toolBar.addSeparator();
        toolBar.add(selectComparisonCartButton);
    }
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    // Progress indicator (not working...)
    toolBar.addSeparator(new Dimension(32, 32));
    toolBar.add(m_progress_indicator);

    // ------ Setup settingspage ------
    final SettingsPage settingsPage = new SettingsPage(jframe, m_rb);
    // Attach observer to it
    settingsPage.addObserver(new Observer() {
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            if (m_shopping_cart != null) {
                // Refresh some stuff
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
        }
    });

    jframe.addWindowListener(new WindowListener() {
        // Use WindowAdapter!
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowClosed(WindowEvent e) {
            m_web_panel.dispose();
            Runtime.getRuntime().exit(0);
        }

        @Override
        public void windowClosing(WindowEvent e) {
            // Save shopping cart
            int index = m_shopping_cart.getCartIndex();
            if (index > 0 && m_web_panel != null)
                m_web_panel.saveShoppingCartWithIndex(index);
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
    print_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            m_web_panel.print();
        }
    });
    settings_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            settingsPage.display();
        }
    });
    quit_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                // Save shopping cart
                int index = m_shopping_cart.getCartIndex();
                if (index > 0 && m_web_panel != null)
                    m_web_panel.saveShoppingCartWithIndex(index);
                // Save settings
                WindowSaver.saveSettings();
                m_web_panel.dispose();
                Runtime.getRuntime().exit(0);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    });
    subscribe_menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI(
                                "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3UM84Z6WLFKZE"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent event) {
            // do nothing
        }

        @Override
        public void menuCanceled(MenuEvent event) {
            // do nothing
        }
    });
    contact_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:zdavatz@ywesee.com?subject=AmiKo%20Desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:info@desitin.ch?subject=AmiKo%20Desktop%20Desitin%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI.create(
                                "mailto:med-drugs@just-medical.com?subject=med-drugs%20desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    report_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            // Check first m_application_folder otherwise resort to
            // pre-installed report
            String report_file = m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_REPORT_BASE
                    + Utilities.appLanguage() + ".html";
            if (!(new File(report_file)).exists())
                report_file = System.getProperty("user.dir") + "/dbs/" + Constants.DEFAULT_AMIKO_REPORT_BASE
                        + Utilities.appLanguage() + ".html";
            // Open report file in browser
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new File(report_file).toURI());
                } catch (IOException e) {
                    // TODO:
                }
            }
        }
    });
    ywesee_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("http://www.ywesee.com/AmiKo/Desktop"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(
                                new URI("http://www.desitin.ch/produkte/arzneimittel-kompendium-apps/"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        if (Utilities.appLanguage().equals("de"))
                            Desktop.getDesktop().browse(new URI("http://www.med-drugs.ch"));
                        else if (Utilities.appLanguage().equals("fr"))
                            Desktop.getDesktop()
                                    .browse(new URI("http://www.med-drugs.ch/index.cfm?&newlang=fr"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    about_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            AmiKoDialogs ad = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
            ad.AboutDialog();
        }
    });

    // Container
    final Container container = jframe.getContentPane();
    container.setBackground(Color.WHITE);
    container.setLayout(new BorderLayout());

    // ==== Toolbar =====
    container.add(toolBar, BorderLayout.NORTH);

    // ==== Left panel ====
    JPanel left_panel = new JPanel();
    left_panel.setBackground(Color.WHITE);
    left_panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(2, 2, 2, 2);

    // ---- Search field ----
    final SearchField searchField = new SearchField("Suche Prparat");
    if (Utilities.appLanguage().equals("fr"))
        searchField.setText("Recherche Specialit");
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(searchField, gbc);
    left_panel.add(searchField, gbc);

    // ---- Buttons ----
    // Names
    String l_title = "Prparat";
    String l_author = "Inhaberin";
    String l_atccode = "Wirkstoff / ATC Code";
    String l_regnr = "Zulassungsnummer";
    String l_ingredient = "Wirkstoff";
    String l_therapy = "Therapie";
    String l_search = "Suche";

    if (Utilities.appLanguage().equals("fr")) {
        l_title = "Spcialit";
        l_author = "Titulaire";
        l_atccode = "Principe Active / Code ATC";
        l_regnr = "Nombre Enregistration";
        l_ingredient = "Principe Active";
        l_therapy = "Thrapie";
        l_search = "Recherche";
    }

    ButtonGroup bg = new ButtonGroup();

    JToggleButton but_title = new JToggleButton(l_title);
    setupToggleButton(but_title);
    bg.add(but_title);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_title, gbc);
    left_panel.add(but_title, gbc);

    JToggleButton but_auth = new JToggleButton(l_author);
    setupToggleButton(but_auth);
    bg.add(but_auth);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_auth, gbc);
    left_panel.add(but_auth, gbc);

    JToggleButton but_atccode = new JToggleButton(l_atccode);
    setupToggleButton(but_atccode);
    bg.add(but_atccode);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_atccode, gbc);
    left_panel.add(but_atccode, gbc);

    JToggleButton but_regnr = new JToggleButton(l_regnr);
    setupToggleButton(but_regnr);
    bg.add(but_regnr);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_regnr, gbc);
    left_panel.add(but_regnr, gbc);

    JToggleButton but_therapy = new JToggleButton(l_therapy);
    setupToggleButton(but_therapy);
    bg.add(but_therapy);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_therapy, gbc);
    left_panel.add(but_therapy, gbc);

    // ---- Card layout ----
    final CardLayout cardl = new CardLayout();
    cardl.setHgap(-4); // HACK to make things look better!!
    final JPanel p_results = new JPanel(cardl);
    m_list_titles = new ListPanel();
    m_list_auths = new ListPanel();
    m_list_regnrs = new ListPanel();
    m_list_atccodes = new ListPanel();
    m_list_ingredients = new ListPanel();
    m_list_therapies = new ListPanel();
    // Contraints
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = 1;
    gbc.gridheight = 10;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    //
    p_results.add(m_list_titles, l_title);
    p_results.add(m_list_auths, l_author);
    p_results.add(m_list_regnrs, l_regnr);
    p_results.add(m_list_atccodes, l_atccode);
    p_results.add(m_list_ingredients, l_ingredient);
    p_results.add(m_list_therapies, l_therapy);

    // --> container.add(p_results, gbc);
    left_panel.add(p_results, gbc);
    left_panel.setBorder(null);
    // First card to show
    cardl.show(p_results, l_title);

    // ==== Right panel ====
    JPanel right_panel = new JPanel();
    right_panel.setBackground(Color.WHITE);
    right_panel.setLayout(new GridBagLayout());

    // ---- Section titles ----
    m_section_titles = null;
    if (Utilities.appLanguage().equals("de")) {
        m_section_titles = new IndexPanel(SectionTitle_DE);
    } else if (Utilities.appLanguage().equals("fr")) {
        m_section_titles = new IndexPanel(SectionTitle_FR);
    }
    m_section_titles.setMinimumSize(new Dimension(150, 150));
    m_section_titles.setMaximumSize(new Dimension(320, 1000));

    // ---- Fachinformation ----
    m_web_panel = new WebPanel2();
    m_web_panel.setMinimumSize(new Dimension(320, 150));

    // Add JSplitPane on the RIGHT
    final int Divider_location = 150;
    final int Divider_size = 10;
    final JSplitPane split_pane_right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, m_section_titles,
            m_web_panel);
    split_pane_right.setOneTouchExpandable(true);
    split_pane_right.setDividerLocation(Divider_location);
    split_pane_right.setDividerSize(Divider_size);

    // Add JSplitPane on the LEFT
    JSplitPane split_pane_left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left_panel,
            split_pane_right /* right_panel */);
    split_pane_left.setOneTouchExpandable(true);
    split_pane_left.setDividerLocation(320); // Sets the pane divider location
    split_pane_left.setDividerSize(Divider_size);
    container.add(split_pane_left, BorderLayout.CENTER);

    // Add status bar on the bottom
    JPanel statusPanel = new JPanel();
    statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16));
    statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
    container.add(statusPanel, BorderLayout.SOUTH);

    final JLabel m_status_label = new JLabel("");
    m_status_label.setHorizontalAlignment(SwingConstants.LEFT);
    statusPanel.add(m_status_label);

    // Add mouse listener
    searchField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            searchField.setText("");
        }
    });

    final String final_title = l_title;
    final String final_author = l_author;
    final String final_atccode = l_atccode;
    final String final_regnr = l_regnr;
    final String final_therapy = l_therapy;
    final String final_search = l_search;

    // Internal class that implements switching between buttons
    final class Toggle {
        public void toggleButton(JToggleButton jbn) {
            for (int i = 0; i < list_of_buttons.length; ++i) {
                if (jbn == list_of_buttons[i])
                    list_of_buttons[i].setSelected(true);
                else
                    list_of_buttons[i].setSelected(false);
            }
        }
    }
    ;

    // ------ Add toolbar action listeners ------
    selectAipsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectAipsButton);
            // Set state 'aips'
            if (!m_curr_uistate.getUseMode().equals("aips")) {
                m_curr_uistate.setUseMode("aips");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        m_query_str = searchField.getText();
                        int num_hits = retrieveAipsSearchResults(false);
                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                        //
                        if (med_index < 0 && prev_med_index >= 0)
                            med_index = prev_med_index;
                        m_web_panel.updateText();
                        if (num_hits == 0) {
                            m_web_panel.emptyPage();
                        }
                    }
                });
            }
        }
    });
    selectFavoritesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectFavoritesButton);
            // Set state 'favorites'
            if (!m_curr_uistate.getUseMode().equals("favorites")) {
                m_curr_uistate.setUseMode("favorites");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // m_query_str = searchField.getText();
                        // Clear the search container
                        med_search.clear();
                        for (String regnr : favorite_meds_set) {
                            List<Medication> meds = m_sqldb.searchRegNr(regnr);
                            if (!meds.isEmpty()) { // Add med database ID
                                med_search.add(meds.get(0));
                            }
                        }
                        // Sort list of meds
                        Collections.sort(med_search, new Comparator<Medication>() {
                            @Override
                            public int compare(final Medication m1, final Medication m2) {
                                return m1.getTitle().compareTo(m2.getTitle());
                            }
                        });

                        sTitle();
                        cardl.show(p_results, final_title);

                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });
    selectInteractionsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectInteractionsButton);
            // Set state 'interactions'
            if (!m_curr_uistate.getUseMode().equals("interactions")) {
                m_curr_uistate.setUseMode("interactions");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_query_str = searchField.getText();
                        retrieveAipsSearchResults(false);
                        // Switch to interaction mode
                        m_web_panel.updateInteractionsCart();
                        m_web_panel.repaint();
                        m_web_panel.validate();
                    }
                });
            }
        }
    });
    selectShoppingCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String email_adr = m_prefs.get("emailadresse", "");
            if (email_adr != null && email_adr.length() > 2) // Two chars is the minimum lenght for an email address
                m_preferences_ok = true;
            if (m_preferences_ok) {
                m_preferences_ok = false; // Check always
                new Toggle().toggleButton(selectShoppingCartButton);
                // Set state 'shopping'
                if (!m_curr_uistate.getUseMode().equals("shopping")) {
                    m_curr_uistate.setUseMode("shopping");
                    // Show middle pane
                    split_pane_right.setDividerSize(Divider_size);
                    split_pane_right.setDividerLocation(Divider_location);
                    m_section_titles.setVisible(true);
                    // Set right panel title
                    m_web_panel.setTitle(m_rb.getString("shoppingCart"));
                    // Switch to shopping cart
                    int index = 1;
                    if (m_shopping_cart != null) {
                        index = m_shopping_cart.getCartIndex();
                        m_web_panel.loadShoppingCartWithIndex(index);
                        // m_shopping_cart.printShoppingBasket();
                    }
                    // m_web_panel.updateShoppingHtml();
                    m_web_panel.updateListOfPackages();
                    if (m_first_pass == true) {
                        m_first_pass = false;
                        if (Utilities.appCustomization().equals("ywesee"))
                            med_search = m_sqldb.searchAuth("ibsa");
                        else if (Utilities.appCustomization().equals("desitin"))
                            med_search = m_sqldb.searchAuth("desitin");
                        sAuth();
                        cardl.show(p_results, final_author);
                    }
                }
            } else {
                selectShoppingCartButton.setSelected(false);
                settingsPage.display();
            }
        }
    });
    selectComparisonCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectComparisonCartButton);
            // Set state 'comparison'
            if (!m_curr_uistate.getUseMode().equals("comparison")) {
                m_curr_uistate.setUseMode("comparison");
                // Hide middle pane
                m_section_titles.setVisible(false);
                split_pane_right.setDividerLocation(0);
                split_pane_right.setDividerSize(0);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // Set right panel title
                        m_web_panel.setTitle(getTitle("priceComp"));
                        if (med_index >= 0) {
                            if (med_id != null && med_index < med_id.size()) {
                                Medication m = m_sqldb.getMediWithId(med_id.get(med_index));
                                String atc_code = m.getAtcCode();
                                if (atc_code != null) {
                                    String atc = atc_code.split(";")[0];
                                    m_web_panel.fillComparisonBasket(atc);
                                    m_web_panel.updateComparisonCartHtml();
                                    // Update pane on the left
                                    retrieveAipsSearchResults(false);
                                }
                            }
                        }

                        m_status_label.setText(rose_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });

    // ------ Add keylistener to text field (type as you go feature) ------
    searchField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) { // keyReleased(KeyEvent e)
            // invokeLater potentially in the wrong place... more testing
            // required
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (m_curr_uistate.isLoadCart())
                        m_curr_uistate.restoreUseMode();
                    m_start_time = System.currentTimeMillis();
                    m_query_str = searchField.getText();
                    // Queries for SQLite DB
                    if (!m_query_str.isEmpty()) {
                        if (m_query_type == 0) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTitle(m_query_str);
                            } else {
                                med_search = m_sqldb.searchTitle(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTitle();
                            cardl.show(p_results, final_title);
                        } else if (m_query_type == 1) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchSupplier(m_query_str);
                            } else {
                                med_search = m_sqldb.searchAuth(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sAuth();
                            cardl.show(p_results, final_author);
                        } else if (m_query_type == 2) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchATC(m_query_str);
                            } else {
                                med_search = m_sqldb.searchATC(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sATC();
                            cardl.show(p_results, final_atccode);
                        } else if (m_query_type == 3) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchEan(m_query_str);
                            } else {
                                med_search = m_sqldb.searchRegNr(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sRegNr();
                            cardl.show(p_results, final_regnr);
                        } else if (m_query_type == 4) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTherapy(m_query_str);
                            } else {
                                med_search = m_sqldb.searchApplication(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTherapy();
                            cardl.show(p_results, final_therapy);
                        } else {
                            // do nothing
                        }
                        int num_hits = 0;
                        if (m_curr_uistate.isComparisonMode())
                            num_hits = rose_search.size();
                        else
                            num_hits = med_search.size();
                        m_status_label.setText(num_hits + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");

                    }
                }
            });
        }
    });

    // Add actionlisteners
    but_title.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_title);
            m_curr_uistate.setQueryType(m_query_type = 0);
            sTitle();
            cardl.show(p_results, final_title);
        }
    });
    but_auth.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_author);
            m_curr_uistate.setQueryType(m_query_type = 1);
            sAuth();
            cardl.show(p_results, final_author);
        }
    });
    but_atccode.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_atccode);
            m_curr_uistate.setQueryType(m_query_type = 2);
            sATC();
            cardl.show(p_results, final_atccode);
        }
    });
    but_regnr.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_regnr);
            m_curr_uistate.setQueryType(m_query_type = 3);
            sRegNr();
            cardl.show(p_results, final_regnr);
        }
    });
    but_therapy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_therapy);
            m_curr_uistate.setQueryType(m_query_type = 4);
            sTherapy();
            cardl.show(p_results, final_therapy);
        }
    });

    // Display window
    jframe.pack();
    // jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    // jframe.setAlwaysOnTop(true);
    jframe.setVisible(true);

    // Check if user has selected an alternative database
    /*
     * NOTE: 21/11/2013: This solution is put on ice. Favored is a solution
     * where the database selected by the user is saved in a default folder
     * (see variable "m_application_data_folder")
     */
    /*
     * try { WindowSaver.loadSettings(jframe); String database_path =
     * WindowSaver.getDbPath(); if (database_path!=null)
     * m_sqldb.loadDBFromPath(database_path); } catch(IOException e) {
     * e.printStackTrace(); }
     */
    // Load AIPS database
    selectAipsButton.setSelected(true);
    selectFavoritesButton.setSelected(false);
    m_curr_uistate.setUseMode("aips");
    med_search = m_sqldb.searchTitle("");
    sTitle(); // Used instead of sTitle (which is slow)
    cardl.show(p_results, final_title);

    // Add menu item listeners
    updatedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (m_mutex_update == false) {
                m_mutex_update = true;
                String db_file = m_maindb_update.doIt(jframe, Utilities.appLanguage(),
                        Utilities.appCustomization(), m_application_data_folder, m_full_db_update);
                // ... and update time
                if (m_full_db_update == true) {
                    DateTime dT = new DateTime();
                    m_prefs.put("updateTime", dT.now().toString());
                }
                //
                if (!db_file.isEmpty()) {
                    // Save db path (can't hurt)
                    WindowSaver.setDbPath(db_file);
                }
            }
        }
    });

    choosedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String db_file = m_maindb_update.chooseFromFile(jframe, Utilities.appLanguage(),
                    Utilities.appCustomization(), m_application_data_folder);
            // ... and update time
            DateTime dT = new DateTime();
            m_prefs.put("updateTime", dT.now().toString());
            //
            if (!db_file.isEmpty()) {
                // Save db path (can't hurt)
                WindowSaver.setDbPath(db_file);
            }
        }
    });

    /**
     * Observers
     */
    // Attach observer to 'm_update'
    m_maindb_update.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Reset flag
            m_full_db_update = true;
            m_mutex_update = false;
            // Refresh some stuff after update
            loadAuthors();
            m_emailer.loadMap();
            settingsPage.load_gln_codes();
            if (m_shopping_cart != null) {
                m_shopping_cart.load_conditions();
                m_shopping_cart.load_glns();
            }
            // Empty shopping basket
            if (m_curr_uistate.isShoppingMode()) {
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
            if (m_curr_uistate.isComparisonMode())
                m_web_panel.setTitle(getTitle("priceComp"));
        }
    });

    // Attach observer to 'm_emailer'
    m_emailer.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Empty shopping basket
            m_shopping_basket.clear();
            int index = m_shopping_cart.getCartIndex();
            if (index > 0)
                m_web_panel.saveShoppingCartWithIndex(index);
            m_web_panel.updateShoppingHtml();
        }
    });

    // Attach observer to "m_comparison_cart"
    m_comparison_cart.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            m_web_panel.setTitle(getTitle("priceComp"));
            m_comparison_cart.clearUploadList();
            m_web_panel.updateComparisonCartHtml();
            new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()).UploadDialog((String) arg);
        }
    });

    // If command line options are provided start app with a particular title or eancode
    if (commandLineOptionsProvided()) {
        if (!CML_OPT_TITLE.isEmpty())
            startAppWithTitle(but_title);
        else if (!CML_OPT_EANCODE.isEmpty())
            startAppWithEancode(but_regnr);
        else if (!CML_OPT_REGNR.isEmpty())
            startAppWithRegnr(but_regnr);
    }

    // Start timer
    Timer global_timer = new Timer();
    // Time checks all 2 minutes (120'000 milliseconds)
    global_timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            checkIfUpdateRequired(updatedb_item);
        }
    }, 2 * 60 * 1000, 2 * 60 * 1000);
}

From source file:examples.monalisa.gui.GeneticDrawingView.java

/** This method is called from within the constructor to
 * initialize the form./*from   w  w w. j  av  a 2s .c  o m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    mainPanel = new javax.swing.JPanel();
    chooseImage = new javax.swing.JButton();
    startEvolution = new javax.swing.JToggleButton();
    targetImageLabel = new javax.swing.JLabel();
    JFreeChart chart = ChartFactory.createXYLineChart("Fitness versus Generation", "Generation", "Fitness",
            new XYSeriesCollection(new XYSeries("")), org.jfree.chart.plot.PlotOrientation.VERTICAL, false,
            false, false);
    chartPanel = new ChartPanel(chart);
    menuBar = new javax.swing.JMenuBar();
    javax.swing.JMenu fileMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenu helpMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
    mainPanel.setName("mainPanel"); // NOI18N
    javax.swing.ActionMap actionMap = org.jdesktop.application.Application
            .getInstance(examples.monalisa.gui.GeneticDrawingApp.class).getContext()
            .getActionMap(GeneticDrawingView.class, this);
    chooseImage.setAction(actionMap.get("chooseImage")); // NOI18N
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application
            .getInstance(examples.monalisa.gui.GeneticDrawingApp.class).getContext()
            .getResourceMap(GeneticDrawingView.class);
    chooseImage.setText(resourceMap.getString("chooseImage.text")); // NOI18N
    chooseImage.setName("chooseImage"); // NOI18N
    startEvolution.setAction(actionMap.get("startEvolution")); // NOI18N
    startEvolution.setText(resourceMap.getString("startEvolution.text")); // NOI18N
    startEvolution.setName("startEvolution"); // NOI18N
    targetImageLabel.setIcon(resourceMap.getIcon("targetImageLabel.icon")); // NOI18N
    targetImageLabel.setText(resourceMap.getString("targetImageLabel.text")); // NOI18N
    targetImageLabel.setName("targetImageLabel"); // NOI18N
    chartPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    chartPanel.setName("chartPanel"); // NOI18N
    org.jdesktop.layout.GroupLayout chartPanelLayout = new org.jdesktop.layout.GroupLayout(chartPanel);
    chartPanel.setLayout(chartPanelLayout);
    chartPanelLayout.setHorizontalGroup(chartPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 399, Short.MAX_VALUE));
    chartPanelLayout.setVerticalGroup(chartPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 234, Short.MAX_VALUE));
    org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
    mainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(mainPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup().add(mainPanelLayout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(mainPanelLayout.createSequentialGroup().add(47, 47, 47).add(chooseImage)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(startEvolution)
                            .add(38, 38, 38))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
                            .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(targetImageLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(80, 80, 80)))
                    .add(chartPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    mainPanelLayout.setVerticalGroup(mainPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, chartPanel,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(mainPanelLayout.createSequentialGroup()
                                    .add(targetImageLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 202,
                                            Short.MAX_VALUE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(mainPanelLayout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                            .add(startEvolution).add(chooseImage))))
                    .addContainerGap()));
    chooseImage.getAccessibleContext()
            .setAccessibleName(resourceMap.getString("jButton1.AccessibleContext.accessibleName")); // NOI18N
    menuBar.setName("menuBar"); // NOI18N
    fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
    fileMenu.setName("fileMenu"); // NOI18N
    exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
    exitMenuItem.setName("exitMenuItem"); // NOI18N
    fileMenu.add(exitMenuItem);
    menuBar.add(fileMenu);
    helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
    helpMenu.setName("helpMenu"); // NOI18N
    aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
    aboutMenuItem.setName("aboutMenuItem"); // NOI18N
    helpMenu.add(aboutMenuItem);
    menuBar.add(helpMenu);
    setComponent(mainPanel);
    setMenuBar(menuBar);
}

From source file:gd.gui.GeneticDrawingView.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from w ww.ja  v a  2  s  . co m
 */
// <editor-fold defaultstate="collapsed" desc="Generated
// Code">//GEN-BEGIN:initComponents
private void initComponents() {

    mainPanel = new javax.swing.JPanel();
    chooseImage = new javax.swing.JButton();
    chooseImage.setVisible(false);
    startEvolution = new javax.swing.JToggleButton();
    startEvolution.setVisible(false);
    targetImageLabel = new javax.swing.JLabel();
    JFreeChart chart = ChartFactory.createXYLineChart("Fitness versus Generation", "Generation", "Fitness",
            new XYSeriesCollection(new XYSeries("")), org.jfree.chart.plot.PlotOrientation.VERTICAL, false,
            false, false);
    chartPanel = new ChartPanel(chart);
    menuBar = new javax.swing.JMenuBar();
    javax.swing.JMenu fileMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
    // javax.swing.JMenu helpMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();

    mainPanel.setName("mainPanel"); // NOI18N

    javax.swing.ActionMap actionMap = org.jdesktop.application.Application
            .getInstance(gd.gui.GeneticDrawingApp.class).getContext()
            .getActionMap(GeneticDrawingView.class, this);
    chooseImage.setAction(actionMap.get("chooseImage")); // NOI18N
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application
            .getInstance(gd.gui.GeneticDrawingApp.class).getContext().getResourceMap(GeneticDrawingView.class);
    chooseImage.setText(resourceMap.getString("chooseImage.text")); // NOI18N
    chooseImage.setName("chooseImage"); // NOI18N

    startEvolution.setAction(actionMap.get("startEvolution")); // NOI18N
    startEvolution.setText(resourceMap.getString("startEvolution.text")); // NOI18N
    startEvolution.setName("startEvolution"); // NOI18N

    targetImageLabel.setIcon(resourceMap.getIcon("targetImageLabel.icon")); // NOI18N
    targetImageLabel.setText(resourceMap.getString("targetImageLabel.text")); // NOI18N
    targetImageLabel.setName("targetImageLabel"); // NOI18N

    chartPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    chartPanel.setName("chartPanel"); // NOI18N

    org.jdesktop.layout.GroupLayout chartPanelLayout = new org.jdesktop.layout.GroupLayout(chartPanel);
    chartPanel.setLayout(chartPanelLayout);
    chartPanelLayout.setHorizontalGroup(chartPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 399, Short.MAX_VALUE));
    chartPanelLayout.setVerticalGroup(chartPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 234, Short.MAX_VALUE));

    org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
    mainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(mainPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup().add(mainPanelLayout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(mainPanelLayout.createSequentialGroup().add(47, 47, 47).add(chooseImage)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(startEvolution)
                            .add(38, 38, 38))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
                            .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(targetImageLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(80, 80, 80)))
                    .add(chartPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    mainPanelLayout.setVerticalGroup(mainPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, chartPanel,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(mainPanelLayout.createSequentialGroup()
                                    .add(targetImageLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 202,
                                            Short.MAX_VALUE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(mainPanelLayout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                            .add(startEvolution).add(chooseImage))))
                    .addContainerGap()));

    chooseImage.getAccessibleContext()
            .setAccessibleName(resourceMap.getString("jButton1.AccessibleContext.accessibleName")); // NOI18N

    menuBar.setName("menuBar"); // NOI18N

    fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
    fileMenu.setName("fileMenu"); // NOI18N

    exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
    exitMenuItem.setName("exitMenuItem"); // NOI18N
    fileMenu.add(exitMenuItem);

    menuBar.add(fileMenu);

    // helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
    // helpMenu.setName("helpMenu"); // NOI18N

    aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
    aboutMenuItem.setName("aboutMenuItem"); // NOI18N
    // helpMenu.add(aboutMenuItem);

    // menuBar.add(helpMenu);

    setComponent(mainPanel);
    setMenuBar(menuBar);
}

From source file:src.examples.monalisa.gui.GeneticDrawingView.java

/** This method is called from within the constructor to
 * initialize the form.//from   ww w . ja  v  a  2  s. c  o  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    mainPanel = new javax.swing.JPanel();
    chooseImage = new javax.swing.JButton();
    startEvolution = new javax.swing.JToggleButton();
    targetImageLabel = new javax.swing.JLabel();
    JFreeChart chart = ChartFactory.createXYLineChart("Fitness versus Generation", "Generation", "Fitness",
            new XYSeriesCollection(new XYSeries("")), org.jfree.chart.plot.PlotOrientation.VERTICAL, false,
            false, false);
    chartPanel = new ChartPanel(chart);
    menuBar = new javax.swing.JMenuBar();
    javax.swing.JMenu fileMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenu helpMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
    mainPanel.setName("mainPanel"); // NOI18N
    javax.swing.ActionMap actionMap = org.jdesktop.application.Application
            .getInstance(src.examples.monalisa.gui.GeneticDrawingApp.class).getContext()
            .getActionMap(GeneticDrawingView.class, this);
    chooseImage.setAction(actionMap.get("chooseImage")); // NOI18N
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application
            .getInstance(src.examples.monalisa.gui.GeneticDrawingApp.class).getContext()
            .getResourceMap(GeneticDrawingView.class);
    chooseImage.setText(resourceMap.getString("chooseImage.text")); // NOI18N
    chooseImage.setName("chooseImage"); // NOI18N
    startEvolution.setAction(actionMap.get("startEvolution")); // NOI18N
    startEvolution.setText(resourceMap.getString("startEvolution.text")); // NOI18N
    startEvolution.setName("startEvolution"); // NOI18N
    targetImageLabel.setIcon(resourceMap.getIcon("targetImageLabel.icon")); // NOI18N
    targetImageLabel.setText(resourceMap.getString("targetImageLabel.text")); // NOI18N
    targetImageLabel.setName("targetImageLabel"); // NOI18N
    chartPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    chartPanel.setName("chartPanel"); // NOI18N
    org.jdesktop.layout.GroupLayout chartPanelLayout = new org.jdesktop.layout.GroupLayout(chartPanel);
    chartPanel.setLayout(chartPanelLayout);
    chartPanelLayout.setHorizontalGroup(chartPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 399, Short.MAX_VALUE));
    chartPanelLayout.setVerticalGroup(chartPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(0, 234, Short.MAX_VALUE));
    org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
    mainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(mainPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup().add(mainPanelLayout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(mainPanelLayout.createSequentialGroup().add(47, 47, 47).add(chooseImage)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(startEvolution)
                            .add(38, 38, 38))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
                            .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(targetImageLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(80, 80, 80)))
                    .add(chartPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    mainPanelLayout.setVerticalGroup(mainPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, mainPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, chartPanel,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(mainPanelLayout.createSequentialGroup()
                                    .add(targetImageLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 202,
                                            Short.MAX_VALUE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(mainPanelLayout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                            .add(startEvolution).add(chooseImage))))
                    .addContainerGap()));
    chooseImage.getAccessibleContext()
            .setAccessibleName(resourceMap.getString("jButton1.AccessibleContext.accessibleName")); // NOI18N
    menuBar.setName("menuBar"); // NOI18N
    fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
    fileMenu.setName("fileMenu"); // NOI18N
    exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
    exitMenuItem.setName("exitMenuItem"); // NOI18N
    fileMenu.add(exitMenuItem);
    menuBar.add(fileMenu);
    helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
    helpMenu.setName("helpMenu"); // NOI18N
    aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
    aboutMenuItem.setName("aboutMenuItem"); // NOI18N
    helpMenu.add(aboutMenuItem);
    menuBar.add(helpMenu);
    setComponent(mainPanel);
    setMenuBar(menuBar);
}