Example usage for javax.swing JLabel setFont

List of usage examples for javax.swing JLabel setFont

Introduction

In this page you can find the example usage for javax.swing JLabel setFont.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.")
public void setFont(Font font) 

Source Link

Document

Sets the font for this component.

Usage

From source file:ca.phon.ipamap.IpaMap.java

/**
 * Create the context menu based on source component
 *//*from   ww  w .j  a v a2  s.c o  m*/
public void setupContextMenu(JPopupMenu menu, JComponent comp) {
    final CommonModuleFrame parentFrame = (CommonModuleFrame) SwingUtilities
            .getAncestorOfClass(CommonModuleFrame.class, comp);
    if (parentFrame != null) {
        final PhonUIAction toggleAlwaysOnTopAct = new PhonUIAction(parentFrame, "setAlwaysOnTop",
                !parentFrame.isAlwaysOnTop());
        toggleAlwaysOnTopAct.putValue(PhonUIAction.NAME, "Always on top");
        toggleAlwaysOnTopAct.putValue(PhonUIAction.SELECTED_KEY, parentFrame.isAlwaysOnTop());
        final JCheckBoxMenuItem toggleAlwaysOnTopItem = new JCheckBoxMenuItem(toggleAlwaysOnTopAct);
        menu.add(toggleAlwaysOnTopItem);
    }

    // button options first
    if (comp instanceof CellButton) {
        CellButton btn = (CellButton) comp;
        Cell cell = btn.cell;

        // copy to clipboard options
        String cellData = cell.getText().replaceAll("" + (char) 0x25cc, "");
        PhonUIAction copyToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", cellData);
        copyToClipboardAct.putValue(PhonUIAction.NAME, "Copy character (" + cell.getText() + ")");
        JMenuItem copyToClipboardItem = new JMenuItem(copyToClipboardAct);
        menu.add(copyToClipboardItem);

        String htmlVal = new String();
        for (Character c : cellData.toCharArray()) {
            htmlVal += "&#" + (int) c + ";";
        }
        PhonUIAction copyHTMLToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", htmlVal);
        copyHTMLToClipboardAct.putValue(PhonUIAction.NAME, "Copy as HTML (" + htmlVal + ")");
        JMenuItem copyHTMLToClipboardItem = new JMenuItem(copyHTMLToClipboardAct);
        menu.add(copyHTMLToClipboardItem);

        String hexVal = new String();
        for (Character c : cellData.toCharArray()) {
            hexVal += (hexVal.length() > 0 ? " " : "") + Integer.toHexString((int) c);
        }
        hexVal = hexVal.toUpperCase();
        PhonUIAction copyHEXToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", hexVal);
        copyHEXToClipboardAct.putValue(PhonUIAction.NAME, "Copy as Unicode HEX (" + hexVal + ")");
        JMenuItem copyHEXToClipboardItem = new JMenuItem(copyHEXToClipboardAct);
        menu.add(copyHEXToClipboardItem);

        menu.addSeparator();
        if (isInFavorites(cell)) {
            PhonUIAction removeFromFavAct = new PhonUIAction(this, "onRemoveCellFromFavorites", cell);
            removeFromFavAct.putValue(Action.NAME, "Remove from favorites");
            removeFromFavAct.putValue(Action.SHORT_DESCRIPTION, "Remove button from list of favorites");
            JMenuItem removeFromFavItem = new JMenuItem(removeFromFavAct);
            menu.add(removeFromFavItem);
        } else {
            PhonUIAction addToFavAct = new PhonUIAction(this, "onAddCellToFavorites", cell);
            addToFavAct.putValue(Action.NAME, "Add to favorites");
            addToFavAct.putValue(Action.SHORT_DESCRIPTION, "Add button to list of favorites");
            JMenuItem addToFavItem = new JMenuItem(addToFavAct);
            menu.add(addToFavItem);
        }
        menu.addSeparator();
    }

    // section scroll-tos
    JMenuItem gotoTitleItem = new JMenuItem("Scroll to:");
    gotoTitleItem.setEnabled(false);
    menu.add(gotoTitleItem);

    for (JXButton toggleBtn : toggleButtons) {
        PhonUIAction gotoAct = new PhonUIAction(this, "onGoto", toggleBtn);
        gotoAct.putValue(Action.NAME, toggleBtn.getText());
        gotoAct.putValue(Action.SHORT_DESCRIPTION, "Scroll to " + toggleBtn.getText());
        JMenuItem gotoItem = new JMenuItem(gotoAct);
        menu.add(gotoItem);
    }

    menu.addSeparator();

    // setup font scaler
    final JLabel smallLbl = new JLabel("A");
    smallLbl.setFont(getFont().deriveFont(12.0f));
    smallLbl.setHorizontalAlignment(SwingConstants.CENTER);
    JLabel largeLbl = new JLabel("A");
    largeLbl.setFont(getFont().deriveFont(24.0f));
    largeLbl.setHorizontalAlignment(SwingConstants.CENTER);

    final JSlider scaleSlider = new JSlider(1, 101);
    scaleSlider.setValue((int) (scale * 100));
    scaleSlider.setMajorTickSpacing(20);
    scaleSlider.setMinorTickSpacing(10);
    scaleSlider.setSnapToTicks(true);
    scaleSlider.setPaintTicks(true);
    scaleSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            int sliderVal = scaleSlider.getValue();

            float scale = (float) sliderVal / (float) 100;

            _cFont = null;

            setSavedScale(scale);
            setScale(scale);

        }
    });

    FormLayout scaleLayout = new FormLayout("3dlu, center:pref, fill:pref:grow, center:pref, 3dlu", "pref");
    CellConstraints cc = new CellConstraints();
    JPanel scalePanel = new JPanel(scaleLayout) {
        @Override
        public Insets getInsets() {
            Insets retVal = super.getInsets();

            retVal.left += UIManager.getIcon("Tree.collapsedIcon").getIconWidth();

            return retVal;
        }
    };
    scalePanel.add(smallLbl, cc.xy(2, 1));
    scalePanel.add(scaleSlider, cc.xy(3, 1));
    scalePanel.add(largeLbl, cc.xy(4, 1));

    JMenuItem scaleItem = new JMenuItem("Font size");
    scaleItem.setEnabled(false);
    menu.add(scaleItem);
    menu.add(scalePanel);

    menu.addSeparator();

    // highlighting
    PhonUIAction onToggleHighlightAct = new PhonUIAction(this, "onToggleHighlightRecent");
    onToggleHighlightAct.putValue(PhonUIAction.NAME, "Highlight recently used");
    onToggleHighlightAct.putValue(PhonUIAction.SELECTED_KEY, isHighlightRecent());
    JCheckBoxMenuItem onToggleHighlightItm = new JCheckBoxMenuItem(onToggleHighlightAct);
    menu.add(onToggleHighlightItm);
}

From source file:org.forester.archaeopteryx.ControlPanel.java

private void setupDisplayCheckboxes() {
    if (_configuration.doDisplayOption(Configuration.display_as_phylogram)) {
        addCheckbox(Configuration.display_as_phylogram,
                _configuration.getDisplayTitle(Configuration.display_as_phylogram));
        setCheckbox(Configuration.display_as_phylogram,
                _configuration.doCheckOption(Configuration.display_as_phylogram));
    }//from  w  ww .  j ava  2 s .  c  om
    if (_configuration.doDisplayOption(Configuration.dynamically_hide_data)) {
        addCheckbox(Configuration.dynamically_hide_data,
                _configuration.getDisplayTitle(Configuration.dynamically_hide_data));
        setCheckbox(Configuration.dynamically_hide_data,
                _configuration.doCheckOption(Configuration.dynamically_hide_data));
    }
    if (_configuration.doDisplayOption(Configuration.node_data_popup)) {
        addCheckbox(Configuration.node_data_popup,
                _configuration.getDisplayTitle(Configuration.node_data_popup));
        setCheckbox(Configuration.node_data_popup, _configuration.doCheckOption(Configuration.node_data_popup));
    }
    //        if ( _configuration.doDisplayOption( Configuration.display_internal_data ) ) {
    //            addCheckbox( Configuration.display_internal_data, _configuration
    //                    .getDisplayTitle( Configuration.display_internal_data ) );
    //            setCheckbox( Configuration.display_internal_data, _configuration
    //                    .doCheckOption( Configuration.display_internal_data ) );
    //        }
    if (_configuration.doDisplayOption(Configuration.color_according_to_species)) {
        addCheckbox(Configuration.color_according_to_species,
                _configuration.getDisplayTitle(Configuration.color_according_to_species));
        setCheckbox(Configuration.color_according_to_species,
                _configuration.doCheckOption(Configuration.color_according_to_species));
    }
    //        if ( _configuration.doDisplayOption( Configuration.color_according_to_annotation ) ) {
    //            addCheckbox( Configuration.color_according_to_annotation, _configuration
    //                    .getDisplayTitle( Configuration.color_according_to_annotation ) );
    //            setCheckbox( Configuration.color_according_to_annotation, _configuration
    //                    .doCheckOption( Configuration.color_according_to_annotation ) );
    //        }

    if (_configuration.doDisplayOption(Configuration.width_branches)) {
        addCheckbox(Configuration.width_branches, _configuration.getDisplayTitle(Configuration.width_branches));
        setCheckbox(Configuration.width_branches, _configuration.doCheckOption(Configuration.width_branches));
    }
    if (_configuration.doDisplayOption(Configuration.show_node_boxes)) {
        addCheckbox(Configuration.show_node_boxes,
                _configuration.getDisplayTitle(Configuration.show_node_boxes));
        setCheckbox(Configuration.show_node_boxes, _configuration.doCheckOption(Configuration.show_node_boxes));
    }
    final JLabel label = new JLabel("Display Data:");
    label.setFont(ControlPanel.jcb_bold_font);
    if (!getConfiguration().isUseNativeUI()) {
        label.setForeground(ControlPanel.jcb_text_color);
    }
    add(label);
    if (_configuration.doDisplayOption(Configuration.show_node_names)) {
        addCheckbox(Configuration.show_node_names,
                _configuration.getDisplayTitle(Configuration.show_node_names));
        setCheckbox(Configuration.show_node_names, _configuration.doCheckOption(Configuration.show_node_names));
    }
    //        if ( _configuration.doDisplayOption( Configuration.show_tax_code ) ) {
    //            addCheckbox( Configuration.show_tax_code, _configuration.getDisplayTitle( Configuration.show_tax_code ) );
    //            setCheckbox( Configuration.show_tax_code, _configuration.doCheckOption( Configuration.show_tax_code ) );
    //        }
    //        if ( _configuration.doDisplayOption( Configuration.show_taxonomy_names ) ) {
    //            addCheckbox( Configuration.show_taxonomy_names, _configuration
    //                    .getDisplayTitle( Configuration.show_taxonomy_names ) );
    //            setCheckbox( Configuration.show_taxonomy_names, _configuration
    //                    .doCheckOption( Configuration.show_taxonomy_names ) );
    //        }
    //        if ( _configuration.doDisplayOption( Configuration.show_gene_symbols ) ) {
    //            addCheckbox( Configuration.show_gene_symbols, _configuration
    //                    .getDisplayTitle( Configuration.show_gene_symbols ) );
    //            setCheckbox( Configuration.show_gene_symbols, _configuration
    //                    .doCheckOption( Configuration.show_gene_symbols ) );
    //        }
    if (_configuration.doDisplayOption(Configuration.show_gene_names)) {
        addCheckbox(Configuration.show_gene_names,
                _configuration.getDisplayTitle(Configuration.show_gene_names));
        setCheckbox(Configuration.show_gene_names, _configuration.doCheckOption(Configuration.show_gene_names));

    }
    //        if ( _configuration.doDisplayOption( Configuration.show_sequence_acc ) ) {
    //            addCheckbox( Configuration.show_sequence_acc, _configuration
    //                    .getDisplayTitle( Configuration.show_sequence_acc ) );
    //            setCheckbox( Configuration.show_sequence_acc, _configuration
    //                    .doCheckOption( Configuration.show_sequence_acc ) );
    //        }
    //        if ( _configuration.doDisplayOption( Configuration.show_annotation ) ) {
    //            addCheckbox( Configuration.show_annotation, _configuration.getDisplayTitle( Configuration.show_annotation ) );
    //            setCheckbox( Configuration.show_annotation, _configuration.doCheckOption( Configuration.show_annotation ) );
    //        }
    //        if ( _configuration.doDisplayOption( Configuration.show_binary_characters ) ) {
    //            addCheckbox( Configuration.show_binary_characters, _configuration
    //                    .getDisplayTitle( Configuration.show_binary_characters ) );
    //            setCheckbox( Configuration.show_binary_characters, _configuration
    //                    .doCheckOption( Configuration.show_binary_characters ) );
    //        }
    //        if ( _configuration.doDisplayOption( Configuration.show_binary_character_counts ) ) {
    //            addCheckbox( Configuration.show_binary_character_counts, _configuration
    //                    .getDisplayTitle( Configuration.show_binary_character_counts ) );
    //            setCheckbox( Configuration.show_binary_character_counts, _configuration
    //                    .doCheckOption( Configuration.show_binary_character_counts ) );
    //        }
    //        if ( _configuration.doDisplayOption( Configuration.show_domain_architectures ) ) {
    //            addCheckbox( Configuration.show_domain_architectures, _configuration
    //                    .getDisplayTitle( Configuration.show_domain_architectures ) );
    //            setCheckbox( Configuration.show_domain_architectures, _configuration
    //                    .doCheckOption( Configuration.show_domain_architectures ) );
    //        }
    //        if ( _configuration.doDisplayOption( Configuration.write_confidence_values ) ) {
    //            addCheckbox( Configuration.write_confidence_values, _configuration
    //                    .getDisplayTitle( Configuration.write_confidence_values ) );
    //            setCheckbox( Configuration.write_confidence_values, _configuration
    //                    .doCheckOption( Configuration.write_confidence_values ) );
    //        }
    //        if ( _configuration.doDisplayOption( Configuration.write_events ) ) {
    //            addCheckbox( Configuration.write_events, _configuration.getDisplayTitle( Configuration.write_events ) );
    //            setCheckbox( Configuration.write_events, _configuration.doCheckOption( Configuration.write_events ) );
    //        }
    final JLabel label2 = new JLabel("Coloring:");
    label2.setFont(ControlPanel.jcb_bold_font);
    if (!getConfiguration().isUseNativeUI()) {
        label2.setForeground(ControlPanel.jcb_text_color);
    }
    add(label2);
    if (_configuration.doDisplayOption(Configuration.color_branches)) {
        addCheckbox(Configuration.color_branches, _configuration.getDisplayTitle(Configuration.color_branches));
        setCheckbox(Configuration.color_branches, _configuration.doCheckOption(Configuration.color_branches));
    }
    if (_configuration.doDisplayOption(Configuration.color_branches_qsbi)) {
        addCheckbox(Configuration.color_branches_qsbi,
                _configuration.getDisplayTitle(Configuration.color_branches_qsbi));
        setCheckbox(Configuration.color_branches_qsbi,
                _configuration.doCheckOption(Configuration.color_branches_qsbi));
    }
    if (_configuration.doDisplayOption(Configuration.color_branches_edpl)) {
        addCheckbox(Configuration.color_branches_edpl,
                _configuration.getDisplayTitle(Configuration.color_branches_edpl));
        setCheckbox(Configuration.color_branches_edpl,
                _configuration.doCheckOption(Configuration.color_branches_edpl));
    }

}

From source file:md.mclama.com.ModManager.java

/**
 * Create the frame./*from  w  w  w. ja v  a2  s.c o  m*/
 */

@SuppressWarnings("serial")
public ModManager() throws MalformedURLException {
    setResizable(false);
    setTitle("McLauncher " + McVersion);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 700, 400);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBounds(0, 0, 694, 372);
    contentPane.add(tabbedPane);

    profileListMdl = new DefaultListModel<String>();
    ModListModel = new DefaultListModel<String>();
    listModel = new DefaultListModel<String>();
    getCurrentMods();

    panelLauncher = new JPanel();
    tabbedPane.addTab("Launcher", null, panelLauncher, null);
    panelLauncher.setLayout(null);
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(556, 36, 132, 248);
    panelLauncher.add(scrollPane);
    profileList = new JList<String>(profileListMdl);
    profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scrollPane.setViewportView(profileList);

    btnNewProfile = new JButton("New");
    btnNewProfile.setFont(new Font("SansSerif", Font.PLAIN, 12));
    btnNewProfile.setBounds(479, 4, 76, 20);
    panelLauncher.add(btnNewProfile);
    btnNewProfile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            newProfile(txtProfile.getText());
        }
    });
    btnNewProfile.setToolTipText("Click to create a new profile.");

    JButton btnRenameProfile = new JButton("Rename");
    btnRenameProfile.setBounds(479, 25, 76, 20);
    panelLauncher.add(btnRenameProfile);
    btnRenameProfile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renameProfile();
        }
    });
    btnRenameProfile.setToolTipText("Click to rename the selected profile");

    JButton btnDelProfile = new JButton("Delete");
    btnDelProfile.setBounds(479, 50, 76, 20);
    panelLauncher.add(btnDelProfile);
    btnDelProfile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            deleteProfile();
        }
    });
    btnDelProfile.setToolTipText("Click to delete the selected profile.");

    JButton btnLaunch = new JButton("Launch");
    btnLaunch.setBounds(605, 319, 89, 23);
    panelLauncher.add(btnLaunch);
    btnLaunch.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (selProfile != null) {
                LaunchFactorioWithSelectedMods(false); //dont ignore
            }
        }
    });
    btnLaunch.setToolTipText("Click to launch factorio with the selected mod profile.");

    lblAvailableMods = new JLabel("Available Mods");
    lblAvailableMods.setBounds(4, 155, 144, 14);
    panelLauncher.add(lblAvailableMods);
    lblAvailableMods.setFont(new Font("SansSerif", Font.PLAIN, 10));

    lblAvailableMods.setText("Available Mods: " + -1);

    txtGamePath = new JTextField();
    txtGamePath.setBounds(4, 5, 211, 23);
    panelLauncher.add(txtGamePath);
    txtGamePath.setToolTipText("Select tha path to your game!");
    txtGamePath.setFont(new Font("Tahoma", Font.PLAIN, 8));
    txtGamePath.setText("Game Path");
    txtGamePath.setColumns(10);

    JButton btnFind = new JButton("find");
    btnFind.setBounds(227, 3, 32, 23);
    panelLauncher.add(btnFind);

    txtProfile = new JTextField();
    txtProfile.setBounds(556, 2, 132, 22);
    panelLauncher.add(txtProfile);
    txtProfile.setToolTipText("The name of NEW or RENAME profiles");
    txtProfile.setText("Profile1");
    txtProfile.setColumns(10);

    lblModsEnabled = new JLabel("Mods Enabled: -1");
    lblModsEnabled.setBounds(335, 155, 95, 16);
    panelLauncher.add(lblModsEnabled);
    lblModsEnabled.setFont(new Font("SansSerif", Font.PLAIN, 10));

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(0, 167, 211, 165);
    panelLauncher.add(scrollPane_1);
    modsList = new JList<String>(listModel);
    modsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    modsList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            String modName = util.getModVersion(modsList.getSelectedValue());
            lblModVersion.setText("Mod Version: " + modName);
            checkDependency(modsList);
            if (modName.contains(".zip")) {
                new File(System.getProperty("java.io.tmpdir") + modName.replace(".zip", "")).delete();
            }
            if (System.currentTimeMillis() - lastClickTime <= 300) { //Double click
                addMod();
            }
            lastClickTime = System.currentTimeMillis();
        }
    });
    scrollPane_1.setViewportView(modsList);
    modsList.setFont(new Font("Tahoma", Font.PLAIN, 9));

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setBounds(333, 167, 211, 165);
    panelLauncher.add(scrollPane_2);
    enabledModsList = new JList<String>(ModListModel);
    enabledModsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    enabledModsList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            lblModVersion.setText("Mod Version: " + util.getModVersion(enabledModsList.getSelectedValue()));
            checkDependency(enabledModsList);
            if (System.currentTimeMillis() - lastClickTime <= 300) { //Double click
                removeMod();
            }
            lastClickTime = System.currentTimeMillis();
        }
    });
    enabledModsList.setFont(new Font("SansSerif", Font.PLAIN, 10));
    scrollPane_2.setViewportView(enabledModsList);

    JButton btnEnable = new JButton("Enable");
    btnEnable.setBounds(223, 200, 90, 28);
    panelLauncher.add(btnEnable);
    btnEnable.setToolTipText("Add mod -->");

    JButton btnDisable = new JButton("Disable");
    btnDisable.setBounds(223, 240, 90, 28);
    panelLauncher.add(btnDisable);
    btnDisable.setToolTipText("Disable mod ");

    JLabel lblModsAvailable = new JLabel("Mods available");
    lblModsAvailable.setBounds(4, 329, 89, 14);
    panelLauncher.add(lblModsAvailable);
    lblModsAvailable.setFont(new Font("SansSerif", Font.PLAIN, 10));

    JLabel lblEnabledMods = new JLabel("Enabled Mods");
    lblEnabledMods.setBounds(337, 329, 89, 16);
    panelLauncher.add(lblEnabledMods);
    lblEnabledMods.setFont(new Font("SansSerif", Font.PLAIN, 10));

    lblModVersion = new JLabel("Mod Version: (select a mod first)");
    lblModVersion.setBounds(4, 117, 183, 14);
    panelLauncher.add(lblModVersion);
    lblModVersion.setFont(new Font("SansSerif", Font.PLAIN, 10));

    lblRequiredMods = new JLabel("Required Mods: " + reqModsStr);
    lblRequiredMods.setBounds(6, 143, 538, 14);
    panelLauncher.add(lblRequiredMods);
    lblRequiredMods.setHorizontalAlignment(SwingConstants.RIGHT);
    lblRequiredMods.setFont(new Font("SansSerif", Font.PLAIN, 10));

    JButton btnNewButton = new JButton("TEST");
    btnNewButton.setVisible(testBtnEnabled);
    btnNewButton.setEnabled(testBtnEnabled);
    btnNewButton.setBounds(338, 61, 90, 28);
    panelLauncher.add(btnNewButton);
    btnUpdate.setBounds(218, 322, 103, 20);
    panelLauncher.add(btnUpdate);

    btnUpdate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            util.updateLauncher();
        }
    });
    btnUpdate.setVisible(false);
    btnUpdate.setFont(new Font("SansSerif", Font.PLAIN, 9));

    lblModRequires = new JLabel("Mod Requires: (Select a mod first)");
    lblModRequires.setBounds(4, 127, 317, 16);
    panelLauncher.add(lblModRequires);

    btnLaunchIgnore = new JButton("Launch + ignore");
    btnLaunchIgnore.setToolTipText("Ignore any errors that McLauncher may not correctly account for.");
    btnLaunchIgnore.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnLaunchIgnore.setBounds(556, 284, 133, 23);
    panelLauncher.add(btnLaunchIgnore);

    JButton btnConsole = new JButton("Console");
    btnConsole.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean changeto = !con.isVisible();
            con.setVisible(changeto);
            con.updateConsole();
        }
    });
    btnConsole.setBounds(335, 0, 90, 28);
    panelLauncher.add(btnConsole);

    JPanel panelDownloadMods = new JPanel();
    tabbedPane.addTab("Download Mods", null, panelDownloadMods, null);
    panelDownloadMods.setLayout(null);

    scrollPane_3 = new JScrollPane();
    scrollPane_3.setBounds(0, 0, 397, 303);
    panelDownloadMods.add(scrollPane_3);

    dlModel = new DefaultTableModel(new Object[][] {},
            new String[] { "Mod Name", "Author", "Version", "Tags" }) {
        Class[] columnTypes = new Class[] { String.class, String.class, String.class, Object.class };

        public Class getColumnClass(int columnIndex) {
            return columnTypes[columnIndex];
        }

        boolean[] columnEditables = new boolean[] { false, false, false, false };

        public boolean isCellEditable(int row, int column) {
            return columnEditables[column];
        };
    };

    tSorter = new TableRowSorter<DefaultTableModel>(dlModel);
    tableDownloads = new JTable();
    tableDownloads.setRowSorter(tSorter);
    tableDownloads.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            trow = tableDownloads.getSelectedRow();
            trow = tableDownloads.getRowSorter().convertRowIndexToModel(trow);
            getDlModData();
            canDownloadMod = true;
        }
    });
    tableDownloads.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            trow = tableDownloads.getSelectedRow();
            trow = tableDownloads.getRowSorter().convertRowIndexToModel(trow);
            getDlModData();
            canDownloadMod = true;
        }
    });
    tableDownloads.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    tableDownloads.setShowVerticalLines(true);
    tableDownloads.setShowHorizontalLines(true);
    tableDownloads.setModel(dlModel);
    tableDownloads.getColumnModel().getColumn(0).setPreferredWidth(218);
    tableDownloads.getColumnModel().getColumn(1).setPreferredWidth(97);
    tableDownloads.getColumnModel().getColumn(2).setPreferredWidth(77);
    scrollPane_3.setViewportView(tableDownloads);

    btnDownload = new JButton("Download");
    btnDownload.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (canDownloadMod && !CurrentlyDownloading) {
                String dlUrl = getModDownloadUrl();
                try {
                    if (dlUrl.equals("") || dlUrl.equals(" ") || dlUrl == null) {
                        con.log("Log", "No download link for mod, got... '" + dlUrl + "'");
                    } else {
                        CurrentlyDownloading = true;
                        CurrentDownload = new Download(new URL(dlUrl), McLauncher);
                    }
                } catch (MalformedURLException e1) {
                    con.log("Log", "Failed to download mod... No download URL?");
                }
            }
        }
    });
    btnDownload.setBounds(307, 308, 90, 28);
    panelDownloadMods.add(btnDownload);

    btnGotoMod = new JButton("Mod Page");
    btnGotoMod.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            util.openWebpage(modPageUrl);
        }
    });
    btnGotoMod.setEnabled(false);
    btnGotoMod.setBounds(134, 308, 90, 28);
    panelDownloadMods.add(btnGotoMod);

    pBarDownloadMod = new JProgressBar();
    pBarDownloadMod.setBounds(538, 308, 150, 10);
    panelDownloadMods.add(pBarDownloadMod);

    pBarExtractMod = new JProgressBar();
    pBarExtractMod.setBounds(538, 314, 150, 10);
    panelDownloadMods.add(pBarExtractMod);

    lblDownloadModInfo = new JLabel("Download progress");
    lblDownloadModInfo.setBounds(489, 326, 199, 16);
    panelDownloadMods.add(lblDownloadModInfo);
    lblDownloadModInfo.setHorizontalAlignment(SwingConstants.TRAILING);

    panelModImg = new JPanel();
    panelModImg.setBounds(566, 0, 128, 128);
    panelDownloadMods.add(panelModImg);

    txtFilterText = new JTextField();
    txtFilterText.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (txtFilterText.getText().equals("Filter Text")) {
                txtFilterText.setText("");
                newFilter();
            }
        }
    });
    txtFilterText.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (!txtFilterText.getText().equals("Filter Text")) {
                newFilter();
            }
        }
    });
    txtFilterText.setText("Filter Text");
    txtFilterText.setBounds(0, 308, 122, 28);
    panelDownloadMods.add(txtFilterText);
    txtFilterText.setColumns(10);

    comboBox = new JComboBox();
    comboBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            newFilter();
        }
    });
    comboBox.setModel(new DefaultComboBoxModel(new String[] { "No tag filter", "Vanilla", "Machine", "Mechanic",
            "New Ore", "Module", "Big Mod", "Power", "GUI", "Map-Gen", "Must-Have", "Equipment" }));
    comboBox.setBounds(403, 44, 150, 26);
    panelDownloadMods.add(comboBox);

    lblModDlCounter = new JLabel("Mod database: ");
    lblModDlCounter.setFont(new Font("SansSerif", Font.PLAIN, 10));
    lblModDlCounter.setBounds(403, 5, 162, 16);
    panelDownloadMods.add(lblModDlCounter);

    txtrDMModDescription = new JTextArea();
    txtrDMModDescription.setBackground(Color.LIGHT_GRAY);
    txtrDMModDescription.setBorder(new LineBorder(new Color(0, 0, 0)));
    txtrDMModDescription.setFocusable(false);
    txtrDMModDescription.setEditable(false);
    txtrDMModDescription.setLineWrap(true);
    txtrDMModDescription.setWrapStyleWord(true);
    txtrDMModDescription.setText("Mod Description: ");
    txtrDMModDescription.setBounds(403, 132, 285, 75);
    panelDownloadMods.add(txtrDMModDescription);

    lblDMModTags = new JTextArea();
    lblDMModTags.setFocusable(false);
    lblDMModTags.setEditable(false);
    lblDMModTags.setBorder(new LineBorder(new Color(0, 0, 0)));
    lblDMModTags.setWrapStyleWord(true);
    lblDMModTags.setLineWrap(true);
    lblDMModTags.setBackground(Color.LIGHT_GRAY);
    lblDMModTags.setText("Mod Tags: ");
    lblDMModTags.setBounds(403, 71, 160, 60);
    panelDownloadMods.add(lblDMModTags);

    lblDMRequiredMods = new JTextArea();
    lblDMRequiredMods.setFocusable(false);
    lblDMRequiredMods.setEditable(false);
    lblDMRequiredMods.setText("Required Mods: ");
    lblDMRequiredMods.setWrapStyleWord(true);
    lblDMRequiredMods.setLineWrap(true);
    lblDMRequiredMods.setBorder(new LineBorder(new Color(0, 0, 0)));
    lblDMRequiredMods.setBackground(Color.LIGHT_GRAY);
    lblDMRequiredMods.setBounds(403, 208, 285, 57);
    panelDownloadMods.add(lblDMRequiredMods);

    lblDLModLicense = new JLabel("");
    lblDLModLicense.setHorizontalAlignment(SwingConstants.RIGHT);
    lblDLModLicense.setBounds(403, 294, 285, 16);
    panelDownloadMods.add(lblDLModLicense);

    lblWipmod = new JLabel("");
    lblWipmod.setBounds(395, 314, 64, 16);
    panelDownloadMods.add(lblWipmod);

    JButton btnCancel = new JButton("Cancel");
    btnCancel.setToolTipText("Stop downloading");
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CurrentDownload.cancel();
        }
    });
    btnCancel.setBounds(230, 308, 72, 28);
    panelDownloadMods.add(btnCancel);

    panelOptions = new JPanel();
    tabbedPane.addTab("Options", null, panelOptions, null);
    panelOptions.setLayout(null);
    scrollPane_4.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane_4.setBounds(0, 0, 694, 342);
    panelOptions.add(scrollPane_4);

    panel = new JPanel();
    scrollPane_4.setViewportView(panel);
    panel.setLayout(null);

    lblCloseMclauncherAfter = new JLabel("Close McLauncher after launching Factorio?");
    lblCloseMclauncherAfter.setBounds(6, 6, 274, 16);
    panel.add(lblCloseMclauncherAfter);

    lblCloseMclauncherAfter_1 = new JLabel("Close McLauncher after updating?");
    lblCloseMclauncherAfter_1.setBounds(6, 34, 274, 16);
    panel.add(lblCloseMclauncherAfter_1);

    lblSortNewestDownloadable = new JLabel("Sort newest downloadable mods first?");
    lblSortNewestDownloadable.setBounds(6, 62, 274, 16);
    panel.add(lblSortNewestDownloadable);

    tglbtnNewModsFirst = new JToggleButton("Toggle");
    tglbtnNewModsFirst.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            lblNeedrestart.setText("McLauncher needs to restart for that to work");
            writeData();
        }
    });
    tglbtnNewModsFirst.setSelected(true);
    tglbtnNewModsFirst.setBounds(281, 56, 66, 28);
    panel.add(tglbtnNewModsFirst);

    tglbtnCloseAfterUpdate = new JToggleButton("Toggle");
    tglbtnCloseAfterUpdate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnCloseAfterUpdate.setBounds(281, 28, 66, 28);
    panel.add(tglbtnCloseAfterUpdate);

    tglbtnCloseAfterLaunch = new JToggleButton("Toggle");
    tglbtnCloseAfterLaunch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnCloseAfterLaunch.setBounds(281, 0, 66, 28);
    panel.add(tglbtnCloseAfterLaunch);

    tglbtnDisplayon = new JToggleButton("On");
    tglbtnDisplayon.setFont(new Font("SansSerif", Font.PLAIN, 10));
    tglbtnDisplayon.setSelected(true);
    tglbtnDisplayon.setBounds(588, 308, 44, 28);
    panel.add(tglbtnDisplayon);

    tglbtnDisplayoff = new JToggleButton("Off");
    tglbtnDisplayoff.setFont(new Font("SansSerif", Font.PLAIN, 10));
    tglbtnDisplayoff.setBounds(644, 308, 44, 28);
    panel.add(tglbtnDisplayoff);

    lblInfo = new JLabel("What enabled and disabled look like");
    lblInfo.setFont(new Font("SansSerif", Font.PLAIN, 10));
    lblInfo.setHorizontalAlignment(SwingConstants.TRAILING);
    lblInfo.setBounds(359, 314, 231, 16);
    panel.add(lblInfo);

    JSeparator separator = new JSeparator();
    separator.setBounds(6, 55, 676, 24);
    panel.add(separator);

    JSeparator separator_1 = new JSeparator();
    separator_1.setBounds(6, 27, 676, 18);
    panel.add(separator_1);

    JSeparator separator_2 = new JSeparator();
    separator_2.setBounds(6, 84, 676, 24);
    panel.add(separator_2);

    JSeparator separator_3 = new JSeparator();
    separator_3.setOrientation(SwingConstants.VERTICAL);
    separator_3.setBounds(346, 0, 16, 336);
    panel.add(separator_3);

    lblNeedrestart = new JLabel("");
    lblNeedrestart.setBounds(6, 314, 341, 16);
    panel.add(lblNeedrestart);

    tglbtnSendAnonData = new JToggleButton("Toggle");
    tglbtnSendAnonData.setToolTipText("Information regarding the activity of McLauncher.");
    tglbtnSendAnonData.setSelected(true); //set enabled by default.
    tglbtnSendAnonData.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnSendAnonData.setBounds(622, 0, 66, 28);
    panel.add(tglbtnSendAnonData);

    lblSendAnonymousUse = new JLabel("Send anonymous use data?");
    lblSendAnonymousUse.setBounds(359, 6, 251, 16);
    panel.add(lblSendAnonymousUse);

    lblDeleteOldMod = new JLabel("Delete old mod before updating?");
    lblDeleteOldMod.setBounds(359, 34, 251, 16);
    panel.add(lblDeleteOldMod);

    tglbtnDeleteBeforeUpdate = new JToggleButton("Toggle");
    tglbtnDeleteBeforeUpdate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnDeleteBeforeUpdate.setBounds(622, 28, 66, 28);
    panel.add(tglbtnDeleteBeforeUpdate);

    tglbtnAlertOnModUpdateAvailable = new JToggleButton("Toggle");
    tglbtnAlertOnModUpdateAvailable.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            writeData();
        }
    });
    tglbtnAlertOnModUpdateAvailable.setSelected(true);
    tglbtnAlertOnModUpdateAvailable.setBounds(281, 86, 66, 28);
    panel.add(tglbtnAlertOnModUpdateAvailable);

    separator_4 = new JSeparator();
    separator_4.setBounds(0, 112, 676, 24);
    panel.add(separator_4);

    JLabel lblAlertModHas = new JLabel("Alert mod has update on launch?");
    lblAlertModHas.setBounds(6, 92, 231, 16);
    panel.add(lblAlertModHas);

    panelChangelog = new JPanel();
    tabbedPane.addTab("Changelog", null, panelChangelog, null);
    panelChangelog.setLayout(new BoxLayout(panelChangelog, BoxLayout.X_AXIS));

    scrollPane_6 = new JScrollPane();
    panelChangelog.add(scrollPane_6);

    textChangelog = new JTextArea();
    scrollPane_6.setViewportView(textChangelog);
    textChangelog.setEditable(false);
    textChangelog.setText(
            "v0.4.6\r\n\r\n+Fix problem where config file would not save in the correct location. (Thanks Arano-kai)\r\n+McLauncher will now save when you select a path, or profile. (Thanks Arano-kai)\r\n+Fixed an issue where McLauncher could not get the version from a .zip mod. (Thanks Arano-kai)\r\n+Added a Cancel button to stop downloading the current mod. (Suggested by  Arano-kai)\r\n\r\n\r\n\r\nv0.4.5\r\n\r\n+McLauncher should now correctly warn you on failed write/read access.\r\n+McLauncher should now work when a user has both zip and installer versions of factorio. (Thanks Jeroon)\r\n+Attempt to fix an error with dependency and .zip files, With versions. (Thanks Arano-kai)\r\n+Fix only allow single selection of mods. (Thanks Arano-kai)\r\n+Fix for the Launch+Ignore button problem on linux being cut off. (Thanks Arano-kai)\r\n+Display download progress.\r\n+Fixed an error that was thrown when clicking on some mods that had a single dependency mod.\r\n+Double clicking on a mod will now enable or disable the mod. (Thanks Arano-kai)");
    btnLaunchIgnore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (selProfile != null) {
                LaunchFactorioWithSelectedMods(true); //ignore errors, launch.
            }
        }
    });
    btnLaunchIgnore.setVisible(false);
    //This is my test button. I use this to test things then implement them into the swing.
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            testButtonCode(e);
        }
    });
    //Disable mods button. (from profile)
    btnDisable.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            removeMod();
        }
    });
    //Enable mods button. (to profile)
    btnEnable.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            addMod();
        }
    });
    //Game path button
    btnFind.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            findPath();
        }
    });
    //mouseClick event lister for when you click on a new profile
    profileList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            selectedProfile();
        }
    });

    readData(); //Load settings

    init(); //some extra init
    getMods(); //Get the mods the user has installed
}

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

/**
 * Reset all day labels back to plain font.
 *///ww  w  .  ja  v  a2  s .  c om
private void resetAllDayLabels() {
    JLabel[] labels = { jLabel9, jLabel10, jLabel11, jLabel12, jLabel13, jLabel14, jLabel5, jLabel6 };
    for (JLabel label : labels) {
        final Font oldFont = label.getFont();
        // Reset BOLD attribute.
        final Font font = oldFont.deriveFont(oldFont.getStyle() & ~Font.BOLD);
        label.setFont(font);
    }
}

From source file:es.emergya.ui.base.LoginWindow.java

private void initialize() {
    ventana.getContentPane().removeAll();
    ventana.setLayout(new BorderLayout());
    ventana.setSize(new Dimension(800, 600));

    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBackground(Color.WHITE);

    JPanel logos = new JPanel(new GridLayout(2, 1));
    logos.add(new JLabel(LogicConstants.getIcon("login_logo_cliente")));
    logos.add(new JLabel(LogicConstants.getIcon("login_logo")));
    logos.setBackground(Color.WHITE);

    JLabel label = new JLabel();
    label.setText(i18n.getString("11")); //$NON-NLS-1$

    JLabel labelUsuario = new JLabel();
    labelUsuario.setText(i18n.getString("12")); //$NON-NLS-1$

    JLabel lablep = new JLabel();
    lablep.setText(i18n.getString("13")); //$NON-NLS-1$

    panel.add(logos, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(error, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(labelUsuario, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(usuario, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(lablep, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(pass, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(conectando, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    panel.add(login, new GridBagConstraints(1, 6, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));

    panel.setBorder(new EmptyBorder(100, 100, 100, 100));

    ventana.add(panel, BorderLayout.CENTER);

    JPanel abajo = new JPanel();

    abajo.setLayout(new FlowLayout(FlowLayout.RIGHT));
    abajo.add(version);//from w w w. j  a  v a  2  s .c  om
    abajo.setOpaque(false);
    ventana.add(abajo, BorderLayout.SOUTH);

    try {
        label.setFont(LogicConstants.deriveBoldFont(20.0f));
        labelUsuario.setFont(LogicConstants.deriveBoldFont(20.0f));
        lablep.setFont(LogicConstants.deriveBoldFont(20.0f));
        login.setFont(LogicConstants.deriveBoldFont(20.0f));
        error.setFont(LogicConstants.getBoldFont());
    } catch (Exception e) {
        LOG.error("Error al inicializar el login", e);
    }
    ventana.setLocationRelativeTo(null);
    // ventana.pack();

}

From source file:com.pironet.tda.TDA.java

private void displayTable(HistogramTableModel htm) {
    setThreadDisplay(false);/*from   ww w  .ja  v a2s .com*/

    htm.setFilter("");
    htm.setShowHotspotClasses(PrefManager.get().getShowHotspotClasses());

    TableSorter ts = new TableSorter(htm);
    histogramTable = new JTable(ts);
    ts.setTableHeader(histogramTable.getTableHeader());
    histogramTable.getColumnModel().getColumn(0).setPreferredWidth(700);
    final ViewScrollPane tableView = new ViewScrollPane(histogramTable, runningAsVisualVMPlugin);

    JPanel histogramView = new JPanel(new BorderLayout());
    JPanel histoStatView = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 0));

    JLabel infoLabel = new JLabel(
            NumberFormat.getInstance().format(htm.getRowCount()) + " classes and base types");
    infoLabel.setFont(SANS_SERIF);
    histoStatView.add(infoLabel);
    infoLabel = new JLabel(NumberFormat.getInstance().format(htm.getBytes()) + " bytes");
    infoLabel.setFont(SANS_SERIF);
    histoStatView.add(infoLabel);
    infoLabel = new JLabel(NumberFormat.getInstance().format(htm.getInstances()) + " live objects");
    infoLabel.setFont(SANS_SERIF);
    histoStatView.add(infoLabel);
    if (htm.isOOM()) {
        infoLabel = new JLabel("<html><b>OutOfMemory found!</b>");
        infoLabel.setFont(SANS_SERIF);
        histoStatView.add(infoLabel);
    }
    if (htm.isIncomplete()) {
        infoLabel = new JLabel("<html><b>Class Histogram is incomplete! (broken logfile?)</b>");
        infoLabel.setFont(SANS_SERIF);
        histoStatView.add(infoLabel);
    }
    JPanel filterPanel = new JPanel(new FlowLayout());
    infoLabel = new JLabel("Filter-Expression");
    infoLabel.setFont(SANS_SERIF);
    filterPanel.add(infoLabel);

    filter = new JTextField(30);
    filter.setFont(SANS_SERIF);
    filter.addCaretListener(new FilterListener(htm));
    filterPanel.add(infoLabel);
    filterPanel.add(filter);
    checkCase = new JCheckBox();
    checkCase.addChangeListener(new CheckCaseListener(htm));
    infoLabel = new JLabel("Ignore Case");
    infoLabel.setFont(SANS_SERIF);
    filterPanel.add(infoLabel);
    filterPanel.add(checkCase);
    histoStatView.add(filterPanel);
    histogramView.add(histoStatView, BorderLayout.SOUTH);
    histogramView.add(tableView, BorderLayout.CENTER);

    histogramView.setPreferredSize(splitPane.getBottomComponent().getSize());

    splitPane.setBottomComponent(histogramView);
}

From source file:com.xilinx.virtex7.MainScreen.java

private Container createContentPane() {
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.setOpaque(true);/*from  w  ww  . j a v  a  2  s .co  m*/

    mainPanel = new JPanel(new BorderLayout());

    mainPanel.setBounds(0, 0, minWidth, minHeight);
    testPanel = new JPanel(new BorderLayout());
    ttabs = new JTabbedPane();
    ttabs.add("DATAPATH 0&1", testAndStats());

    if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV
            || mode == LandingPage.APPLICATION_MODE || mode == LandingPage.APPLICATION_MODE_P2P) // condition for placing dynamic tabs. a kcah
        ttabs.add("DATAPATH 2&3", testAndStatsSecondTab());
    else
        testAndStatsSecondTab();

    testPanel.add(ttabs, BorderLayout.CENTER);
    testPanel.add(messageBox(), BorderLayout.PAGE_END);

    mainPanel.add(testPanel, BorderLayout.LINE_START);

    //Make the center component big, since that's the
    //typical usage of BorderLayout.
    tabs = new JTabbedPane();

    mainPanel.add(tabs, BorderLayout.CENTER);

    tabs.add("System Monitor", pciInfo());
    tabs.add("Performance Plots", plotPanel());

    mainPanel.setOpaque(true);

    try {
        imagePanel = new ImageBackgroundPanel(blockDiagram, false);
    } catch (Exception e) {
    }
    /*imagePanel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Design Block Diagram"),
                BorderFactory.createEmptyBorder(5,5,5,5)));*/
    imagePanel.setBackground(Color.WHITE);
    imagePanel.setSize(minWidth, minHeight);

    imagePanel.setLocation(0, 0);
    imagePanel.setOpaque(true);

    final JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(minWidth, minHeight));
    layeredPane.add(mainPanel, JLayeredPane.DEFAULT_LAYER, 0);
    layeredPane.add(imagePanel, JLayeredPane.DEFAULT_LAYER, 0);
    layeredPane.addComponentListener(new ComponentListener() {

        @Override
        public void componentResized(ComponentEvent ce) {
            mainPanel.setBounds(0, 0, Math.max(minWidth, layeredPane.getWidth()),
                    Math.max(minHeight, layeredPane.getHeight()));
            if (layeredPane.getWidth() > 1024) {
                tplotPanel.setPreferredSize(new Dimension(300, 100));
            } else {
                tplotPanel.setPreferredSize(new Dimension(200, 100));
            }
            imagePanel.setSize(mainPanel.getWidth(), mainPanel.getHeight());
            imagePanel.setLocation(0, 0);
            mainPanel.repaint();
        }

        @Override
        public void componentMoved(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void componentShown(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void componentHidden(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    // on top, but invisible initially
    imagePanel.setVisible(false);

    JPanel bpanel = new JPanel(new BorderLayout());

    final JButton button = new JButton(
            "<html><b>B<br>L<br>O<br>C<br>K<br> <br>D<br>I<br>A<br>G<br>R<br>A<br>M<br></b></html>");
    button.setToolTipText("Click here to see the block diagram");
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            adjustSelectionPanel();
        }
    });

    bpanel.add(button, BorderLayout.CENTER);

    contentPane.add(layeredPane, BorderLayout.CENTER);
    contentPane.add(button, BorderLayout.EAST);
    JPanel panel = new JPanel(new BorderLayout());

    JLabel mLabel = new JLabel(modeText, JLabel.CENTER);
    mLabel.setFont(new Font(modeText, Font.BOLD, 15));
    panel.add(mLabel, BorderLayout.PAGE_START);

    JPanel ledPanel = new JPanel(new BorderLayout());

    JPanel iledPanel = new JPanel();
    iledPanel.setLayout(new BoxLayout(iledPanel, BoxLayout.X_AXIS));

    led_ddr3_1 = new JLabel("DDR3 0", new ImageIcon(led1), JLabel.CENTER);
    led_ddr3_2 = new JLabel("DDR3 1", new ImageIcon(led1), JLabel.CENTER);
    led_phy0 = new JLabel("PHY 0", new ImageIcon(led1), JLabel.CENTER);
    led_phy1 = new JLabel("PHY 1", new ImageIcon(led1), JLabel.CENTER);
    led_phy2 = new JLabel("PHY 2", new ImageIcon(led1), JLabel.CENTER);
    led_phy3 = new JLabel("PHY 3", new ImageIcon(led1), JLabel.CENTER);

    JPanel le1 = new JPanel(new BorderLayout());
    le1.add(led_ddr3_1, BorderLayout.CENTER);

    JPanel le2 = new JPanel(new BorderLayout());
    le2.add(led_ddr3_2, BorderLayout.CENTER);

    JPanel le3 = new JPanel(new BorderLayout());
    le3.add(led_phy0, BorderLayout.CENTER);

    JPanel le4 = new JPanel(new BorderLayout());
    le4.add(led_phy1, BorderLayout.CENTER);

    JPanel le5 = new JPanel(new BorderLayout());
    le5.add(led_phy2, BorderLayout.CENTER);

    JPanel le6 = new JPanel(new BorderLayout());
    le6.add(led_phy3, BorderLayout.CENTER);

    iledPanel.add(le1);
    iledPanel.add(le2);
    iledPanel.add(le3);
    iledPanel.add(le4);
    iledPanel.add(le5);
    iledPanel.add(le6);

    if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
        startAll_tooltip = "This will start tests on all data paths";
        startAlltests = new JButton("Start All");
        startAlltests.setToolTipText(startAll_tooltip);
        startAlltests.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                if (startAlltests.getText().equals("Start All")) {
                    startAll_tooltip = "This will stop tests on all data paths";
                    startAlltests.setToolTipText(startAll_tooltip);
                    // check whether any tests are already started
                    String message = "";
                    if (testStarted || testStarted1)
                        message = "Test(s) on Path 0&1 are running. Cannot do Start All";
                    if (testStarted2 || testStarted3) {
                        if (message.length() > 0) // test 1 and 0 are also running
                            message = "Test(s) on Path 0&1 and 2&3 are running. Cannot do Start All";
                        else
                            message = "Test(s) on Path 2&3 are running. Cannot do Start All";
                    }
                    if (message.length() > 0) {
                        JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
                    } else {
                        String ledsMsg = checkLedsState();
                        // condition to check the ddr and py leds are enable or not
                        if (ledsMsg.length() == 0) {
                            startAlltests.setEnabled(false);
                            startAlltests.setText("Stop All");

                            startTest.doClick();
                            stest.doClick();
                            s3test.doClick();
                            s4test.doClick();

                            // disable all buttons
                            startTest.setEnabled(false);
                            stest.setEnabled(false);
                            s3test.setEnabled(false);
                            s4test.setEnabled(false);

                            startAlltests.setEnabled(true);
                        } else {// shows alert when leds are disabled                                
                            JOptionPane.showMessageDialog(null, ledsMsg, "Error", JOptionPane.ERROR_MESSAGE);
                        }

                    }
                } else {
                    startAlltests.setEnabled(false);
                    startAll_tooltip = "This will start tests on all data paths";
                    startAlltests.setToolTipText(startAll_tooltip);
                    /*
                    startTest.setEnabled(true);
                    stest.setEnabled(true);
                    s3test.setEnabled(true);
                    s4test.setEnabled(true);
                            
                    s3test.doClick();
                    s4test.doClick();
                    startTest.doClick();
                    stest.doClick();
                    */
                    SwingWorker worker = new SwingWorker<Void, Void>() {
                        @Override
                        protected Void doInBackground() throws Exception {
                            try {
                                stopTest4();
                                s4test.setEnabled(false);
                                stopTest3();
                                s3test.setEnabled(false);
                                stopTest2();
                                stest.setEnabled(false);
                                stopTest1();
                                startTest.setEnabled(false);

                                startAlltests.setText("Start All");
                                startAlltests.setEnabled(true);
                                startTest.setEnabled(true);
                                stest.setEnabled(true);
                                s3test.setEnabled(true);
                                s4test.setEnabled(true);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            return null;
                        }

                    };
                    worker.execute();
                }
            }
        });
        iledPanel.add(startAlltests);
    }
    ledPanel.add(iledPanel, BorderLayout.CENTER);

    //tstats.add(ledPanel);
    panel.add(ledPanel, BorderLayout.CENTER);
    contentPane.add(panel, BorderLayout.PAGE_START);
    return contentPane;
}

From source file:it.isislab.dmason.tools.batch.BatchWizard.java

/**
 * Create the frame.//from w w w. ja v a2  s  .c o m
 */
public BatchWizard() {
    setPreferredSize(new Dimension(800, 600));
    setTitle("Batch wizard");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 849, 620);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new GridLayout(1, 0, 0, 0));

    JPanel panel = new JPanel();
    panel.setToolTipText("");
    contentPane.add(panel);

    panel_1 = new JPanel();
    panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Param Option",
            TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));

    JPanel panel_2 = new JPanel();
    panel_2.setBorder(
            new TitledBorder(null, "Params List", TitledBorder.LEADING, TitledBorder.TOP, null, null));

    JPanel panel_3 = new JPanel();

    JPanel panel_4 = new JPanel();
    GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGroup(gl_panel
            .createSequentialGroup().addContainerGap()
            .addComponent(
                    panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
                    .addGroup(gl_panel.createSequentialGroup()
                            .addComponent(panel_4, GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE).addGap(20))
                    .addGroup(gl_panel.createSequentialGroup()
                            .addComponent(panel_2, GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE).addGap(4))))
            .addComponent(panel_3, GroupLayout.DEFAULT_SIZE, 823, Short.MAX_VALUE));
    gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.TRAILING).addGroup(gl_panel
            .createSequentialGroup()
            .addComponent(panel_3, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
                    .addGroup(gl_panel.createSequentialGroup()
                            .addComponent(panel_2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addGap(25)
                            .addComponent(panel_4, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE))
                    .addComponent(panel_1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addContainerGap()));

    final JButton btnSave = new JButton("Save");
    btnSave.setEnabled(false);
    btnSave.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {

            File saveFile = SaveFileChooser();
            createXML(saveFile.getAbsoluteFile().getPath());
        }
    });

    lblTotTests = new JLabel(totTestsMessage);
    GroupLayout gl_panel_4 = new GroupLayout(panel_4);
    gl_panel_4.setHorizontalGroup(gl_panel_4.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_4.createSequentialGroup().addGap(21).addComponent(lblTotTests)
                    .addPreferredGap(ComponentPlacement.RELATED, 515, Short.MAX_VALUE).addComponent(btnSave)
                    .addGap(21)));
    gl_panel_4.setVerticalGroup(gl_panel_4.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_4.createSequentialGroup().addContainerGap()
                    .addGroup(gl_panel_4.createParallelGroup(Alignment.BASELINE).addComponent(btnSave)
                            .addComponent(lblTotTests))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    panel_4.setLayout(gl_panel_4);

    top = new DefaultMutableTreeNode("Parameters");

    JScrollPane scrollPaneTree = new JScrollPane();

    JLabel lblNumberOfWorkers = new JLabel("Number of Workers:");

    textFieldNumberOfWorkers = new JTextField();
    textFieldNumberOfWorkers.setText("1");
    textFieldNumberOfWorkers.setColumns(10);
    textFieldNumberOfWorkers.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            if (textFieldNumberOfWorkers.isVisible()) {
                boolean checkNumberOfWorkers = true;

                while (checkNumberOfWorkers) {

                    String dist = textFieldNumberOfWorkers.getText();
                    boolean validateDist = dist.matches("(\\d)+");
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldNumberOfWorkers.setText(newDist);
                    }

                    else {
                        checkNumberOfWorkers = false;
                    }
                }
            }
        }
    });

    checkBoxLoadBalancing = new JCheckBox("Load Balancing", false);
    checkBoxLoadBalancing.setEnabled(true);

    GroupLayout gl_panel_2 = new GroupLayout(panel_2);
    gl_panel_2.setHorizontalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_2
            .createSequentialGroup().addContainerGap()
            .addGroup(gl_panel_2.createParallelGroup(Alignment.LEADING)
                    .addComponent(scrollPaneTree, GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
                    .addGroup(gl_panel_2.createSequentialGroup().addComponent(lblNumberOfWorkers)
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addComponent(textFieldNumberOfWorkers, GroupLayout.PREFERRED_SIZE, 46,
                                    GroupLayout.PREFERRED_SIZE))
                    .addComponent(checkBoxLoadBalancing, GroupLayout.PREFERRED_SIZE, 114,
                            GroupLayout.PREFERRED_SIZE))
            .addContainerGap()));
    gl_panel_2.setVerticalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_2
            .createSequentialGroup().addContainerGap()
            .addComponent(scrollPaneTree, GroupLayout.PREFERRED_SIZE, 271, GroupLayout.PREFERRED_SIZE)
            .addGap(33)
            .addGroup(gl_panel_2.createParallelGroup(Alignment.BASELINE).addComponent(lblNumberOfWorkers)
                    .addComponent(textFieldNumberOfWorkers, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(checkBoxLoadBalancing, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
            .addContainerGap(56, Short.MAX_VALUE)));

    final JTree treeParams = new JTree(top);
    scrollPaneTree.setViewportView(treeParams);
    treeParams.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent selected) {
            // DefaultMutableTreeNode parent =
            // selected.getPath().getParentPath()

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeParams.getLastSelectedPathComponent();
            if (node.getParent() != null) {
                if (node.getParent() == simParams || node.getParent().equals(generalParams)) {

                    selectedParam = (Param) node.getUserObject();
                    if (node.getParent() == simParams) {
                        selectedParamIndex = simParams.getIndex(node);
                        paramType = "simParam";
                    }

                    else {
                        selectedParamIndex = generalParams.getIndex(node);
                        paramType = "generalParam";
                    }
                    if (selectedParam instanceof ParamFixed) {
                        ParamFixed pf = (ParamFixed) selectedParam;
                        lblParamType.setText(pf.getName() + ": " + pf.getType());
                        if (suggestion.get(pf.getName()) != null) {
                            lblDomain.setText("Domain: " + suggestion.get(pf.getName()).getDomain());
                            lblSuggested.setText(
                                    "Suggested Value: " + suggestion.get(pf.getName()).getSuggestedValue());
                        }

                        textFieldRuns.setText("" + pf.getRuns());
                        textFieldValue.setText(pf.getValue());
                        rdbtnFixed.doClick();

                        lblMessage.setVisible(false);
                        setModifyControlEnable(true);

                    }

                    if (selectedParam instanceof ParamRange) {
                        ParamRange pf = (ParamRange) selectedParam;
                        lblParamType.setText(pf.getName() + ": " + pf.getType());
                        if (suggestion.get(pf.getName()) != null) {
                            lblDomain.setText("Domain: " + suggestion.get(pf.getName()).getDomain());
                            lblSuggested.setText(
                                    "Suggested Value: " + suggestion.get(pf.getName()).getSuggestedValue());
                        }
                        textFieldRuns.setText("" + pf.getRuns());
                        textFieldStartValue.setText(pf.getStart());
                        textFieldEndValue.setText(pf.getEnd());
                        textFieldIncrement.setText(pf.getIncrement());
                        rdbtnRange.doClick();

                        lblMessage.setVisible(false);
                        setModifyControlEnable(true);
                    }

                    if (selectedParam instanceof ParamList) {
                        ParamList pl = (ParamList) selectedParam;
                        if (suggestion.get(pl.getName()) != null) {
                            lblDomain.setText("Domain: " + suggestion.get(pl.getName()).getDomain());
                            lblSuggested.setText(
                                    "Suggested Value: " + suggestion.get(pl.getName()).getSuggestedValue());
                        }
                        lblParamType.setText(pl.getName() + ": " + pl.getType());
                        textFieldRuns.setText("" + pl.getRuns());
                        StringBuilder b = new StringBuilder();
                        boolean isFirst = true;
                        for (String element : pl.getValues()) {
                            if (isFirst) {
                                b.append(element);
                                isFirst = false;
                            } else
                                b.append("," + element);
                        }
                        textFieldList.setText(b.toString());
                        rdbtnByvalues.doClick();

                        setListControlvisibility(true);
                        lblMessage.setVisible(false);
                        setModifyControlEnable(true);
                    }
                    if (selectedParam instanceof ParamDistribution) {
                        DistributionType distType = DistributionType.none;
                        if (selectedParam instanceof ParamDistributionUniform) {
                            ParamDistributionUniform pu = (ParamDistributionUniform) selectedParam;
                            lblParamType.setText(pu.getName() + ": " + pu.getType());
                            if (suggestion.get(pu.getName()) != null) {
                                lblDomain.setText("Domain: " + suggestion.get(pu.getName()).getDomain());
                                lblSuggested.setText(
                                        "Suggested Value: " + suggestion.get(pu.getName()).getSuggestedValue());
                            }

                            textFieldRuns.setText("" + pu.getRuns());
                            textFieldA.setText(pu.getA());
                            textFieldB.setText(pu.getB());
                            textFieldNumberOfValues.setText("" + pu.getNumberOfValues());
                            distType = DistributionType.uniform;
                        }
                        if (selectedParam instanceof ParamDistributionExponential) {
                            ParamDistributionExponential pe = (ParamDistributionExponential) selectedParam;
                            lblParamType.setText(pe.getName() + ": " + pe.getType());
                            if (suggestion.get(pe.getName()) != null) {

                                lblDomain.setText("Domain: " + suggestion.get(pe.getName()).getDomain());
                                lblSuggested.setText(
                                        "Suggested Value: " + suggestion.get(pe.getName()).getSuggestedValue());
                            }

                            textFieldRuns.setText("" + pe.getRuns());
                            textFieldA.setText(pe.getLambda());
                            textFieldNumberOfValues.setText("" + pe.getNumberOfValues());
                            distType = DistributionType.exponential;
                        }
                        if (selectedParam instanceof ParamDistributionNormal) {
                            ParamDistributionNormal pn = (ParamDistributionNormal) selectedParam;
                            lblParamType.setText(pn.getName() + ": " + pn.getType());
                            if (suggestion.get(pn.getName()) != null) {
                                lblDomain.setText("Domain: " + suggestion.get(pn.getName()).getDomain());
                                lblSuggested.setText(
                                        "Suggested Value: " + suggestion.get(pn.getName()).getSuggestedValue());
                            }

                            textFieldRuns.setText("" + pn.getRuns());
                            textFieldA.setText(pn.getMean());
                            textFieldB.setText(pn.getStdDev());
                            textFieldNumberOfValues.setText("" + pn.getNumberOfValues());
                            distType = DistributionType.normal;

                        }

                        rdbtnByDistribution.doClick();
                        setDistributionControlVisibility(distType);
                        setDistributionComboBoxVisibility(true);
                        lblMessage.setVisible(false);
                        setModifyControlEnable(true);
                    }
                }
            }
        }
    });

    panel_2.setLayout(gl_panel_2);

    JLabel lblSelectSimulationJar = new JLabel("Select simulation jar:");

    textFieldSimJarPath = new JTextField();
    textFieldSimJarPath.setColumns(10);

    btnLoadParams = new JButton("Load Params");
    btnLoadParams.setEnabled(false);
    btnLoadParams.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ArrayList<Param> params = loadParams();
            if (params != null) {
                top.removeAllChildren();
                createNodes(top, params);
                treeParams.expandPath(new TreePath(top.getPath()));
                treeParams.expandPath(new TreePath(simParams.getPath()));
                treeParams.expandPath(new TreePath(generalParams.getPath()));
            }

            lblTotTests.setText(totTestsMessage + " " + getTotTests());
            btnSave.setEnabled(true);
        }
    });

    JButton bntChooseSimulation = new JButton();
    bntChooseSimulation.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            simulationFile = showFileChooser();
            if (simulationFile != null) {
                textFieldSimJarPath.setText(simulationFile.getAbsolutePath());
                btnLoadParams.setEnabled(true);

                isThin = isThinSimulation(simulationFile);
                checkBoxLoadBalancing.setEnabled(!isThin);

            }
        }

    });
    bntChooseSimulation.setIcon(
            new ImageIcon(BatchWizard.class.getResource("/it.isislab.dmason/resource/image/openFolder.png")));
    GroupLayout gl_panel_3 = new GroupLayout(panel_3);
    gl_panel_3.setHorizontalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_3
            .createSequentialGroup().addContainerGap().addComponent(lblSelectSimulationJar)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addComponent(textFieldSimJarPath, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(bntChooseSimulation, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
            .addGap(26).addComponent(btnLoadParams).addContainerGap(172, Short.MAX_VALUE)));
    gl_panel_3.setVerticalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_3
            .createSequentialGroup().addContainerGap()
            .addGroup(gl_panel_3.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_3
                    .createParallelGroup(Alignment.BASELINE).addComponent(lblSelectSimulationJar)
                    .addComponent(textFieldSimJarPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(bntChooseSimulation, GroupLayout.PREFERRED_SIZE, 25,
                            GroupLayout.PREFERRED_SIZE))
                    .addComponent(btnLoadParams))
            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    panel_3.setLayout(gl_panel_3);

    lblParamType = new JLabel("Param : type");
    lblParamType.setFont(new Font("Tahoma", Font.BOLD, 11));

    JLabel lblRuns = new JLabel("Runs:");
    textFieldRuns = new JTextField();
    textFieldRuns.setColumns(10);
    textFieldRuns.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            if (textFieldRuns.isVisible()) {
                boolean checkRuns = true;

                while (checkRuns) {

                    String dist = textFieldRuns.getText();
                    boolean validateDist = dist.matches("(\\d)+");
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldRuns.setText(newDist);
                    }

                    else {
                        checkRuns = false;
                    }
                }
            }
        }
    });
    JLabel lblParameterSpace = new JLabel("Parameter Space");
    lblParameterSpace.setFont(new Font("Tahoma", Font.BOLD, 11));

    lblValue = new JLabel("Value:");

    textFieldValue = new JTextField();
    textFieldValue.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            String regex = "(\\d)+|((\\d)+\\.(\\d)+)";
            if (textFieldValue.isVisible()) {
                boolean checkValue = true;

                while (checkValue) {

                    String dist = textFieldValue.getText();
                    boolean validateDist = dist.matches(regex);
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldValue.setText(newDist);
                    }

                    else {
                        checkValue = false;
                    }
                }
            }
        }
    });
    textFieldValue.setColumns(10);
    /*textFieldValue.addKeyListener(new KeyListener() {
            
       @Override
       public void keyTyped(KeyEvent arg0) {}
            
       @Override
       public void keyReleased(KeyEvent arg0) {
    checkError();
            
            
       }
            
       @Override
       public void keyPressed(KeyEvent arg0) {}
    });
    */
    lblStartValue = new JLabel("Start value:");

    textFieldStartValue = new JTextField();
    textFieldStartValue.setText("1");
    textFieldStartValue.setColumns(10);
    textFieldStartValue.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            String regex = "(\\d)+|((\\d)+\\.(\\d)+)";
            if (textFieldStartValue.isVisible()) {
                boolean checkStartValue = true;

                while (checkStartValue) {

                    String dist = textFieldStartValue.getText();
                    boolean validateDist = dist.matches(regex);
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldStartValue.setText(newDist);
                    }

                    else {
                        checkStartValue = false;
                    }
                }
            }
        }
    });

    lblEndValue = new JLabel("End value:");

    textFieldEndValue = new JTextField();
    textFieldEndValue.setText("1");
    textFieldEndValue.setColumns(10);
    textFieldEndValue.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            String regex = "(\\d)+|((\\d)+\\.(\\d)+)";
            if (textFieldEndValue.isVisible()) {
                boolean checkEndValue = true;

                while (checkEndValue) {

                    String dist = textFieldEndValue.getText();
                    boolean validateDist = dist.matches(regex);
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldEndValue.setText(newDist);
                    }

                    else {
                        checkEndValue = false;
                    }
                }
            }
        }
    });

    lblIncrement = new JLabel("Increment:");

    textFieldIncrement = new JTextField();
    textFieldIncrement.setText("1");
    textFieldIncrement.setColumns(10);
    textFieldIncrement.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            String regex = "(\\d)+|((\\d)+\\.(\\d)+)";
            if (textFieldIncrement.isVisible()) {

                boolean checkIncrement = true;

                while (checkIncrement) {

                    String dist = textFieldIncrement.getText();
                    boolean validateDist = dist.matches(regex);
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldIncrement.setText(newDist);
                    }

                    else {
                        checkIncrement = false;
                    }
                }
            }
        }
    });

    rdbtnFixed = new JRadioButton("Fixed");
    rdbtnFixed.setSelected(true);
    rdbtnFixed.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {

            setListControlvisibility(false);
            setDistributionComboBoxVisibility(false);
            setRangeControlVisibility(false);
            setFixedControlVisibility(true);
            setDistributionControlVisibility(DistributionType.none);
        }

    });

    rdbtnRange = new JRadioButton("Range");
    rdbtnRange.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setRangeControlVisibility(true);
            setFixedControlVisibility(false);
            setListControlvisibility(false);
            setDistributionComboBoxVisibility(false);
            setDistributionControlVisibility(DistributionType.none);
        }
    });

    rdbtnByvalues = new JRadioButton("By Values");
    rdbtnByvalues.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setRangeControlVisibility(false);
            setFixedControlVisibility(false);
            setListControlvisibility(true);
            setDistributionComboBoxVisibility(false);
            setDistributionControlVisibility(DistributionType.none);
        }
    });
    rdbtnByDistribution = new JRadioButton("By Distribution");
    rdbtnByDistribution.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setRangeControlVisibility(false);
            setFixedControlVisibility(false);
            setListControlvisibility(false);
            setDistributionComboBoxVisibility(true);
            setDistributionControlVisibility(DistributionType.none);
        }
    });
    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(rdbtnFixed);
    group.add(rdbtnRange);
    group.add(rdbtnByvalues);
    group.add(rdbtnByDistribution);

    setRangeControlVisibility(false);
    setFixedControlVisibility(false);

    lblMessage = new JLabel(message);

    btnModify = new JButton("Modify");
    btnModify.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            if (rdbtnFixed.isSelected()) {
                ParamFixed param = new ParamFixed(selectedParam.getName(), selectedParam.getType(),
                        Integer.parseInt(textFieldRuns.getText()), textFieldValue.getText());
                DefaultMutableTreeNode p = new DefaultMutableTreeNode(param);

                if (paramType.equals("simParam")) {
                    simParams.remove(selectedParamIndex);

                    simParams.insert(p, selectedParamIndex);
                } else {
                    generalParams.remove(selectedParamIndex);

                    generalParams.insert(p, selectedParamIndex);
                }

                treeParams.updateUI();

                /*
                 * ((ParamFixed)
                 * selectedParam).setValue(textFieldValue.getText());
                 * selectedParam
                 * .setRuns(Integer.parseInt(textFieldRuns.getText()));
                 * treeParams.repaint();
                 */
            }
            if (rdbtnRange.isSelected()) {
                ParamRange param = new ParamRange(selectedParam.getName(), selectedParam.getType(),
                        Integer.parseInt(textFieldRuns.getText()), textFieldStartValue.getText(),
                        textFieldEndValue.getText(), textFieldIncrement.getText());
                DefaultMutableTreeNode p = new DefaultMutableTreeNode(param);

                if (paramType.equals("simParam")) {
                    simParams.remove(selectedParamIndex);

                    simParams.insert(p, selectedParamIndex);
                } else {
                    generalParams.remove(selectedParamIndex);

                    generalParams.insert(p, selectedParamIndex);
                }
                treeParams.updateUI();
                // treeParams.repaint();

            }
            if (rdbtnByvalues.isSelected()) {
                StringTokenizer st = new StringTokenizer(textFieldList.getText(), ",");
                ArrayList<String> values = new ArrayList<String>();
                while (st.hasMoreTokens())
                    values.add(st.nextToken());

                ParamList param = new ParamList(selectedParam.getName(), selectedParam.getType(),
                        Integer.parseInt(textFieldRuns.getText()), values);
                DefaultMutableTreeNode p = new DefaultMutableTreeNode(param);

                if (paramType.equals("simParam")) {
                    simParams.remove(selectedParamIndex);

                    simParams.insert(p, selectedParamIndex);
                } else {
                    generalParams.remove(selectedParamIndex);

                    generalParams.insert(p, selectedParamIndex);
                }
                treeParams.updateUI();
                // treeParams.repaint();

            }
            if (rdbtnByDistribution.isSelected()) {
                DefaultMutableTreeNode p;
                switch (selectedDistribution) {
                case uniform:

                    p = new DefaultMutableTreeNode(
                            new ParamDistributionUniform(selectedParam.getName(), selectedParam.getType(),
                                    Integer.parseInt(textFieldRuns.getText()), textFieldA.getText(),
                                    textFieldB.getText(), Integer.parseInt(textFieldNumberOfValues.getText())));
                    break;
                case exponential:

                    p = new DefaultMutableTreeNode(new ParamDistributionExponential(selectedParam.getName(),
                            selectedParam.getType(), Integer.parseInt(textFieldRuns.getText()),
                            textFieldA.getText(), Integer.parseInt(textFieldNumberOfValues.getText())));
                    break;

                case normal:

                    p = new DefaultMutableTreeNode(
                            new ParamDistributionNormal(selectedParam.getName(), selectedParam.getType(),
                                    Integer.parseInt(textFieldRuns.getText()), textFieldA.getText(),
                                    textFieldA.getText(), Integer.parseInt(textFieldNumberOfValues.getText())));
                    break;
                default:
                    p = new DefaultMutableTreeNode();
                    break;
                }

                if (paramType.equals("simParam")) {
                    simParams.remove(selectedParamIndex);

                    simParams.insert(p, selectedParamIndex);
                } else {
                    generalParams.remove(selectedParamIndex);

                    generalParams.insert(p, selectedParamIndex);
                }
                treeParams.updateUI();
                // treeParams.repaint();

            }
            lblMessage.setVisible(true);
            setModifyControlEnable(false);
            setDistributionControlVisibility(DistributionType.none);
            setDistributionComboBoxVisibility(false);
            setListControlvisibility(false);

            int tot = getTotTests();
            if (tot >= testAlertThreshold)
                lblTotTests.setForeground(Color.RED);
            else
                lblTotTests.setForeground(Color.BLACK);

            lblTotTests.setText(totTestsMessage + " " + tot);

        }
    });

    btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            lblMessage.setVisible(true);
            setModifyControlEnable(false);

        }
    });

    lblCommaSeparatedList = new JLabel("List:");
    lblCommaSeparatedList.setVisible(false);

    textFieldList = new JTextField();
    textFieldList.setVisible(false);
    textFieldList.setToolTipText("Comma separated");
    textFieldList.setColumns(10);
    textFieldList.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            /*if(textFieldList.isVisible())
            {
            boolean checkList=true;
                    
            while(checkList){
                    
               String dist=textFieldList.getText();
               boolean validateDist=dist.matches("(\\d)+|((\\d)+\\.(\\d)+)(,(\\d)+|((\\d)+\\.(\\d)+))*");
               if(!validateDist){   
                  String   newDist=  JOptionPane.showInputDialog(null,"Insert comma separate number list","Number Format Error", 0);
                  textFieldList.setText(newDist);
               }
                    
               else{
                  checkList=false;
               }
            }
            }*/
        }
    });

    lblDistribution = new JLabel("Distribution");
    lblDistribution.setVisible(false);

    lblA = new JLabel("a:");
    lblA.setVisible(false);

    textFieldA = new JTextField();
    textFieldA.setText("1");
    textFieldA.setVisible(false);
    textFieldA.setColumns(10);
    textFieldA.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            String regex = "(\\d)+|((\\d)+\\.(\\d)+)";

            if (textFieldA.isVisible()) {
                boolean checkA = true;

                while (checkA) {

                    String dist = textFieldA.getText();
                    boolean validateDist = dist.matches(regex);
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldA.setText(newDist);
                    }

                    else {
                        checkA = false;
                    }
                }
            }
        }
    });

    lblB = new JLabel("b:");
    lblB.setVisible(false);

    textFieldB = new JTextField();
    textFieldB.setText("1");
    textFieldB.setVisible(false);
    textFieldB.setColumns(10);
    textFieldB.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {

            String regex = "(\\d)+|((\\d)+\\.(\\d)+)";
            if (textFieldB.isVisible()) {
                boolean checkB = true;

                while (checkB) {

                    String dist = textFieldB.getText();
                    boolean validateDist = dist.matches(regex);
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldB.setText(newDist);
                    }

                    else {
                        checkB = false;
                    }
                }
            }
        }
    });
    jComboBoxDistribution = new JComboBox();
    jComboBoxDistribution.setVisible(false);
    jComboBoxDistribution.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            // Prevent executing listener's actions two times
            if (e.getStateChange() != ItemEvent.SELECTED)
                return;
            selectedDistribution = ((DistributionType) jComboBoxDistribution.getSelectedItem());

            setDistributionControlVisibility(DistributionType.none);
            setDistributionControlVisibility(selectedDistribution);

        }
    });

    lblOfValues = new JLabel("# of values:");
    lblOfValues.setVisible(false);

    textFieldNumberOfValues = new JTextField();
    textFieldNumberOfValues.setText("1");
    textFieldNumberOfValues.setVisible(false);
    textFieldNumberOfValues.setColumns(10);
    textFieldNumberOfValues.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            if (textFieldNumberOfValues.isVisible()) {
                boolean checkNumberOfValues = true;

                while (checkNumberOfValues) {

                    String dist = textFieldNumberOfValues.getText();
                    boolean validateDist = dist.matches("(\\d)+");
                    if (!validateDist) {
                        String newDist = JOptionPane.showInputDialog(null, "Insert a number",
                                "Number Format Error", 0);
                        textFieldNumberOfValues.setText(newDist);
                    }

                    else {
                        checkNumberOfValues = false;
                    }
                }
            }
        }
    });

    lblSuggested = new JLabel("Suggested Value:");

    lblDomain = new JLabel("Domain:");

    GroupLayout gl_panel_1 = new GroupLayout(panel_1);
    gl_panel_1.setHorizontalGroup(gl_panel_1.createParallelGroup(Alignment.TRAILING).addGroup(gl_panel_1
            .createSequentialGroup().addContainerGap()
            .addGroup(gl_panel_1.createParallelGroup(Alignment.TRAILING).addGroup(gl_panel_1
                    .createSequentialGroup()
                    .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING).addComponent(lblParamType)
                            .addComponent(lblMessage).addComponent(lblSuggested))
                    .addContainerGap(77, Short.MAX_VALUE))
                    .addGroup(gl_panel_1.createSequentialGroup().addComponent(btnModify)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnCancel)
                            .addContainerGap())
                    .addGroup(gl_panel_1.createSequentialGroup().addGroup(gl_panel_1
                            .createParallelGroup(Alignment.LEADING).addComponent(lblParameterSpace)
                            .addGroup(gl_panel_1.createSequentialGroup()
                                    .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
                                            .addComponent(rdbtnFixed).addComponent(rdbtnRange))
                                    .addGap(31)
                                    .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
                                            .addComponent(rdbtnByDistribution).addComponent(rdbtnByvalues)))
                            .addGroup(gl_panel_1.createSequentialGroup().addGroup(gl_panel_1
                                    .createParallelGroup(Alignment.TRAILING)
                                    .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblValue)
                                            .addPreferredGap(ComponentPlacement.RELATED, 59, Short.MAX_VALUE)
                                            .addComponent(textFieldValue, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(Alignment.LEADING,
                                            gl_panel_1.createSequentialGroup().addComponent(lblStartValue)
                                                    .addPreferredGap(ComponentPlacement.RELATED, 46,
                                                            Short.MAX_VALUE)
                                                    .addComponent(textFieldStartValue,
                                                            GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE))
                                    .addGroup(gl_panel_1.createSequentialGroup()
                                            .addComponent(lblCommaSeparatedList)
                                            .addPreferredGap(ComponentPlacement.RELATED, 69, Short.MAX_VALUE)
                                            .addComponent(textFieldList, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(gl_panel_1.createSequentialGroup()
                                            .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
                                                    .addComponent(lblEndValue).addComponent(lblIncrement)
                                                    .addComponent(lblDistribution))
                                            .addGap(45)
                                            .addGroup(gl_panel_1.createParallelGroup(Alignment.TRAILING)
                                                    .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
                                                            .addGroup(gl_panel_1
                                                                    .createParallelGroup(Alignment.LEADING,
                                                                            false)
                                                                    .addComponent(jComboBoxDistribution, 0,
                                                                            GroupLayout.DEFAULT_SIZE,
                                                                            Short.MAX_VALUE)
                                                                    .addComponent(textFieldA,
                                                                            GroupLayout.PREFERRED_SIZE,
                                                                            GroupLayout.DEFAULT_SIZE,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(textFieldB,
                                                                            GroupLayout.PREFERRED_SIZE,
                                                                            GroupLayout.DEFAULT_SIZE,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(textFieldNumberOfValues,
                                                                            GroupLayout.PREFERRED_SIZE,
                                                                            GroupLayout.DEFAULT_SIZE,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(textFieldIncrement, 89, 89, 89))
                                                    .addComponent(textFieldEndValue, GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE))))
                                    .addPreferredGap(ComponentPlacement.RELATED, 8, GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblA).addPreferredGap(
                                    ComponentPlacement.RELATED, 173, GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblB).addPreferredGap(
                                    ComponentPlacement.RELATED, 173, GroupLayout.PREFERRED_SIZE))
                            .addComponent(lblOfValues)
                            .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblRuns)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(textFieldRuns, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED, 65,
                                            GroupLayout.PREFERRED_SIZE)))
                            .addGap(35))
                    .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblDomain).addContainerGap(186,
                            Short.MAX_VALUE)))));
    gl_panel_1.setVerticalGroup(gl_panel_1.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_1
            .createSequentialGroup().addGap(4).addComponent(lblMessage).addGap(18).addComponent(lblParamType)
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblSuggested)
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblDomain).addGap(7)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(lblRuns).addComponent(
                    textFieldRuns, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblParameterSpace)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(rdbtnFixed)
                    .addComponent(rdbtnByvalues))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(rdbtnRange)
                    .addComponent(rdbtnByDistribution))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
                    .addComponent(textFieldValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblValue))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
                    .addComponent(textFieldList, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCommaSeparatedList))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(lblStartValue)
                    .addComponent(textFieldStartValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(lblEndValue).addComponent(
                    textFieldEndValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
                    .addComponent(textFieldIncrement, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIncrement))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
                    .addComponent(jComboBoxDistribution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblDistribution))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(gl_panel_1
                    .createParallelGroup(Alignment.BASELINE).addComponent(lblA).addComponent(textFieldA,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl_panel_1
                    .createParallelGroup(Alignment.BASELINE).addComponent(lblB).addComponent(textFieldB,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(lblOfValues).addComponent(
                    textFieldNumberOfValues, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED, 18, Short.MAX_VALUE).addGroup(gl_panel_1
                    .createParallelGroup(Alignment.BASELINE).addComponent(btnModify).addComponent(btnCancel))));
    panel_1.setLayout(gl_panel_1);
    panel.setLayout(gl_panel);

    setModifyControlEnable(false);
    loadDistribution();
}

From source file:Creator.WidgetPanel.java

private void _List_WidgetCodeListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event__List_WidgetCodeListValueChanged

    // _ScrollPane_WidgetSettings
    if (!evt.getValueIsAdjusting()) {

        // Load the variables of the widget
        String widgetCodeStr;/*from   w ww.j a va2 s.com*/
        WidgetCode wc = null;
        WidgetLink wl = null;
        if (!_JTree_WidgetLinks.isSelectionEmpty()) {

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) _JTree_WidgetLinks
                    .getLastSelectedPathComponent();

            if (node == null) //Nothing is selected.  
            {
                return;
            }

            if (node.getParent() != null) {
                String s = node.getParent().toString() + "-" + node.getUserObject().toString();

                if (ws.containsKey(s)) {
                    wl = ws.get(s);
                    wc = widgetList.get(wl.getWidgetCodeName());
                }
            }
        }

        if (wc == null) {
            // No selected item on the JTree
            widgetCodeStr = _List_WidgetCodeList.getSelectedValue().toString();
            wc = widgetList.get(widgetCodeStr);
        } else {

            // Make sure the item selected matches the code in the widget link
            // This makes selecting 
            if (!wc.getWidgetName().equals(_List_WidgetCodeList.getSelectedValue().toString())) {

                widgetCodeStr = _List_WidgetCodeList.getSelectedValue().toString();
                wc = widgetList.get(widgetCodeStr);
            }

        }

        GridBagLayout gbl = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();

        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridx = 0;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 0;
        c.gridwidth = 1;
        c.gridheight = 1;
        c.ipadx = 0;
        c.ipady = 5;

        if (widgetCodeSettings == null) {
            widgetCodeSettings = new HashMap<>();
        } else {
            widgetCodeSettings.clear();
        }

        _Panel_WidgetSettings.removeAll();
        _Panel_WidgetSettings.setLayout(gbl);

        for (String name : wc.getVariables()) {
            JLabel label = new JLabel(name);
            label.setFont(new Font("Arial", Font.BOLD, 13));
            label.setHorizontalAlignment(SwingConstants.CENTER);
            JTextField textfield = new JTextField("");
            textfield.setHorizontalAlignment(SwingConstants.CENTER);
            if (wl != null) {
                textfield.setText(wl.getVariables().get(name));
            }

            textfield.setFont(new Font("Arial", Font.BOLD, 15));

            widgetCodeSettings.put(label.getText(), textfield);
            _Panel_WidgetSettings.add(label, c);
            c.gridy += 1;
            _Panel_WidgetSettings.add(textfield, c);
            c.gridy += 1;
        }

        _ScrollPane_WidgetSettings.revalidate();
        _ScrollPane_WidgetSettings.repaint();

    }

}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatPanel.java

/**
 * Sets the chat session to associate to this chat panel.
 * @param chatSession the chat session to associate to this chat panel
 *///from www.  j ava2 s .c o  m
public void setChatSession(ChatSession chatSession) {
    if (this.chatSession != null) {
        // remove old listener
        this.chatSession.removeChatTransportChangeListener(this);
    }

    this.chatSession = chatSession;
    this.chatSession.addChatTransportChangeListener(this);

    if ((this.chatSession != null) && this.chatSession.isContactListSupported()) {
        topPanel.remove(conversationPanelContainer);

        TransparentPanel rightPanel = new TransparentPanel(new BorderLayout());
        Dimension chatConferencesListsPanelSize = new Dimension(150, 25);
        Dimension chatContactsListsPanelSize = new Dimension(150, 175);
        Dimension rightPanelSize = new Dimension(150, 200);
        rightPanel.setMinimumSize(rightPanelSize);
        rightPanel.setPreferredSize(rightPanelSize);

        TransparentPanel contactsPanel = new TransparentPanel(new BorderLayout());
        contactsPanel.setMinimumSize(chatContactsListsPanelSize);
        contactsPanel.setPreferredSize(chatContactsListsPanelSize);

        conferencePanel.setMinimumSize(chatConferencesListsPanelSize);
        conferencePanel.setPreferredSize(chatConferencesListsPanelSize);

        this.chatContactListPanel = new ChatRoomMemberListPanel(this);
        this.chatContactListPanel.setOpaque(false);

        topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        topSplitPane.setBorder(null); // remove default borders
        topSplitPane.setOneTouchExpandable(true);
        topSplitPane.setOpaque(false);
        topSplitPane.setResizeWeight(1.0D);

        Color msgNameBackground = Color.decode(ChatHtmlUtils.MSG_NAME_BACKGROUND);

        // add border to the divider
        if (topSplitPane.getUI() instanceof BasicSplitPaneUI) {
            ((BasicSplitPaneUI) topSplitPane.getUI()).getDivider()
                    .setBorder(BorderFactory.createLineBorder(msgNameBackground));
        }

        ChatTransport chatTransport = chatSession.getCurrentChatTransport();

        JPanel localUserLabelPanel = new JPanel(new BorderLayout());
        JLabel localUserLabel = new JLabel(chatTransport.getProtocolProvider().getAccountID().getDisplayName());

        localUserLabel.setFont(localUserLabel.getFont().deriveFont(Font.BOLD));
        localUserLabel.setHorizontalAlignment(SwingConstants.CENTER);
        localUserLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 3, 0));
        localUserLabel.setForeground(Color.decode(ChatHtmlUtils.MSG_IN_NAME_FOREGROUND));

        localUserLabelPanel.add(localUserLabel, BorderLayout.CENTER);
        localUserLabelPanel.setBackground(msgNameBackground);

        JButton joinConference = new JButton(
                GuiActivator.getResources().getI18NString("service.gui.JOIN_VIDEO"));

        joinConference.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                showChatConferenceDialog();
            }
        });
        contactsPanel.add(localUserLabelPanel, BorderLayout.NORTH);
        contactsPanel.add(chatContactListPanel, BorderLayout.CENTER);

        conferencePanel.add(joinConference, BorderLayout.CENTER);

        rightPanel.add(conferencePanel, BorderLayout.NORTH);
        rightPanel.add(contactsPanel, BorderLayout.CENTER);

        topSplitPane.setLeftComponent(conversationPanelContainer);
        topSplitPane.setRightComponent(rightPanel);

        topPanel.add(topSplitPane);

    } else {
        if (topSplitPane != null) {
            if (chatContactListPanel != null) {
                topSplitPane.remove(chatContactListPanel);
                chatContactListPanel = null;
            }

            this.messagePane.remove(topSplitPane);
            topSplitPane = null;
        }

        topPanel.add(conversationPanelContainer);
    }

    if (chatSession instanceof MetaContactChatSession) {
        // The subject panel is added here, because it's specific for the
        // multi user chat and is not contained in the single chat chat panel.
        if (subjectPanel != null) {
            this.remove(subjectPanel);
            subjectPanel = null;

            this.revalidate();
            this.repaint();
        }

        writeMessagePanel.initPluginComponents();
        writeMessagePanel.setTransportSelectorBoxVisible(true);

        //Enables to change the protocol provider by simply pressing the
        // CTRL-P key combination
        ActionMap amap = this.getActionMap();

        amap.put("ChangeProtocol", new ChangeTransportAction());

        InputMap imap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK), "ChangeProtocol");
    } else if (chatSession instanceof ConferenceChatSession) {
        ConferenceChatSession confSession = (ConferenceChatSession) chatSession;

        writeMessagePanel.setTransportSelectorBoxVisible(false);

        confSession.addLocalUserRoleListener(this);
        confSession.addMemberRoleListener(this);

        ChatRoom room = ((ChatRoomWrapper) chatSession.getDescriptor()).getChatRoom();
        room.addMemberPropertyChangeListener(this);

        setConferencesPanelVisible(room.getCachedConferenceDescriptionSize() > 0);
        subjectPanel = new ChatRoomSubjectPanel((ConferenceChatSession) chatSession);

        // The subject panel is added here, because it's specific for the
        // multi user chat and is not contained in the single chat chat panel.
        this.add(subjectPanel, BorderLayout.NORTH);

        this.revalidate();
        this.repaint();
    }

    if (chatContactListPanel != null) {
        // Initialize chat participants' panel.
        Iterator<ChatContact<?>> chatParticipants = chatSession.getParticipants();

        while (chatParticipants.hasNext())
            chatContactListPanel.addContact(chatParticipants.next());
    }
}