Example usage for javax.swing.border EmptyBorder EmptyBorder

List of usage examples for javax.swing.border EmptyBorder EmptyBorder

Introduction

In this page you can find the example usage for javax.swing.border EmptyBorder EmptyBorder.

Prototype

public EmptyBorder(int top, int left, int bottom, int right) 

Source Link

Document

Creates an empty border with the specified insets.

Usage

From source file:au.org.ala.delta.intkey.ui.CharacterImageDialog.java

private void init(List<Character> characters, Character dependentCharacter, boolean valuesEditable) {
    ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(CharacterImageDialog.class);
    resourceMap.injectFields(this);

    _characters = characters;//from   w w  w .j a va 2 s.  c o m
    _valuesEditable = valuesEditable;
    getContentPane().setLayout(new BorderLayout(0, 0));

    buildMenuItems();

    if (dependentCharacter != null) {
        if (characters.size() != 1) {
            throw new IllegalArgumentException(
                    "Dependent character should only be supplied if there is a single character being viewed in the dialog");
        }

        Character ch = characters.get(0);

        _pnlControllingCharacterMessage = new JPanel();
        _pnlControllingCharacterMessage.setFocusable(false);
        _pnlControllingCharacterMessage.setBorder(new EmptyBorder(5, 0, 0, 0));
        getContentPane().add(_pnlControllingCharacterMessage, BorderLayout.NORTH);
        _pnlControllingCharacterMessage.setLayout(new BorderLayout(0, 0));

        _lblWarningIcon = new JLabel("");
        _lblWarningIcon.setFocusable(false);
        _lblWarningIcon.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
        _pnlControllingCharacterMessage.add(_lblWarningIcon, BorderLayout.WEST);

        _txtControllingCharacterMessage = new JTextArea();
        CharacterFormatter formatter = new CharacterFormatter(true, CommentStrippingMode.RETAIN,
                AngleBracketHandlingMode.REMOVE_SURROUNDING_REPLACE_INNER, true, false);
        String setControllingCharacterMessage = UIUtils.getResourceString(
                "MultiStateInputDialog.setControllingCharacterMessage",
                formatter.formatCharacterDescription(dependentCharacter),
                formatter.formatCharacterDescription(ch));
        _txtControllingCharacterMessage.setText(setControllingCharacterMessage);
        _txtControllingCharacterMessage.setFocusable(false);
        _txtControllingCharacterMessage.setBorder(new EmptyBorder(0, 5, 0, 0));
        _txtControllingCharacterMessage.setEditable(false);
        _pnlControllingCharacterMessage.add(_txtControllingCharacterMessage);
        _txtControllingCharacterMessage.setWrapStyleWord(true);
        _txtControllingCharacterMessage.setFont(UIManager.getFont("Button.font"));
        _txtControllingCharacterMessage.setLineWrap(true);
        _txtControllingCharacterMessage.setBackground(SystemColor.control);
    }
}

From source file:net.daboross.outputtablesclient.gui.OutputInterface.java

@Override
public void onUpdate(final RobotTable table, final String key, final String value, final UpdateAction action) {
    if (!application.getOutput().getNameTable().contains(table.getName())) {
        return;/*from w w w . ja  v  a  2 s . c om*/
    }
    if (action == UpdateAction.NEW) {
        //            if (key.equalsIgnoreCase(":RangeGUI")) {
        //                Output.oLog("Range: %s", value);
        //                try {
        //                    application.getCustomInterface().setTo(Double.parseDouble(value));
        //                } catch (NumberFormatException ex) {
        //                    Output.oLog("Invalid range '%s'", value);
        //                }
        //            }
        ensureTableExists(table.getName());
        JPanel panel = new JPanel(new GridBagLayout());
        panel.setBorder(new LineBorder(Color.BLACK));
        tableKeyAndKeyToValuePanel.get(table.getName()).put(key, panel);

        JLabel keyLabel = new JLabel(key);
        keyLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
        panel.add(keyLabel, new GBC().fill(GridBagConstraints.VERTICAL).gridy(0));

        JSeparator separator = new JSeparator(JSeparator.VERTICAL);
        separator.setPreferredSize(new Dimension(2, 20));
        panel.add(separator, new GBC().fill(GridBagConstraints.VERTICAL).gridy(0));

        JLabel valueLabel = new JLabel(value);
        valueLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
        panel.add(valueLabel, new GBC().fill(GridBagConstraints.VERTICAL).gridy(0));
        tableKeyAndKeyToValueLabel.get(table.getName()).put(key, valueLabel);

        JPanel parentPanel = tableKeyToTablePanel.get(table.getName());
        parentPanel.add(panel);
        parentPanel.revalidate();
    } else if (action == UpdateAction.UPDATE) {
        //            if (key.equalsIgnoreCase(":RangeGUI")) {
        //                Output.oLog("Range: %s", value);
        //                try {
        //                    application.getCustomInterface().setTo(Double.parseDouble(value));
        //                } catch (NumberFormatException ex) {
        //                    Output.oLog("Invalid range '%s'", value);
        //                }
        //            }
        ensureTableExists(table.getName());
        JLabel valueLabel = tableKeyAndKeyToValueLabel.get(table.getName()).get(key);
        valueLabel.setText(value);
    } else if (action == UpdateAction.DELETE) {
        if (tableKeyToTablePanel.get(table.getName()) == null) {
            return;
        }
        JPanel parentPanel = tableKeyToTablePanel.get(table.getName());
        JPanel valuePanel = tableKeyAndKeyToValuePanel.get(table.getName()).remove(key);
        parentPanel.remove(valuePanel);
        parentPanel.revalidate();
    }
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopPopupButton.java

@Override
public void setCaption(String caption) {
    captionLabel.setText(caption);//from ww w  . j  a  v  a 2s . c  om

    if (StringUtils.isNotEmpty(caption) || icon != null) {
        rightIcon.setBorder(new EmptyBorder(0, 5, 0, 0));
    } else {
        rightIcon.setBorder(null);
    }
}

From source file:com.opendoorlogistics.studio.scripts.editor.ScriptEditor.java

/**
 * Create the frame./*w  ww . j  a v a  2 s  . co  m*/
 */
public ScriptEditor(ODLApi api, Script script, File file, final ScriptUIManager runner) {
    super(file != null ? file.getAbsolutePath() : null);
    this.script = script;
    this.file = file;
    this.runner = runner;
    this.api = api;

    Icon icon = ScriptIcons.getIcon(api, script);
    if (icon != null) {
        setFrameIcon(icon);
    }

    // save the current XML of the script
    lastOutputXML = getXML();

    setSize(DisplayConstants.LEVEL1_SIZE);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout());

    // create toolbar
    reinitialiseToolbar();

    //      JCheckBox syncBox = createSyncCheckbox(script);
    //      bottomToolbarSyncCheckbox = syncBox;
    //      if(bottomToolbarSyncCheckbox!=null){
    //         bottomToolbarSyncCheckbox.addActionListener(new ActionListener() {
    //            
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //               syncCheckboxChanged();
    //            }
    //         });
    //         toolBar.add(bottomToolbarSyncCheckbox);         
    //      }
    //      toolBar.addSeparator();
    //      fillToolbar(toolBar, actions);

    // override close operation
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addInternalFrameListener(new InternalFrameListener() {

        @Override
        public void internalFrameOpened(InternalFrameEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void internalFrameIconified(InternalFrameEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void internalFrameDeiconified(InternalFrameEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void internalFrameDeactivated(InternalFrameEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void internalFrameClosing(InternalFrameEvent e) {
            disposeWithSavePrompt();
        }

        @Override
        public void internalFrameClosed(InternalFrameEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void internalFrameActivated(InternalFrameEvent e) {
            // TODO Auto-generated method stub

        }
    });

    if (runner != null) {
        runner.registerDatastoreStructureChangedListener(dsStructureChangedListener);
    }

    toolBar.updateEnabled();
    updateTitle();
}

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

/**
 * Create the frame./* w w w  .j a va2  s  .  co 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:au.com.jwatmuff.eventmanager.gui.main.MainWindow.java

private void createPanels() {
    printPanel = new PrintPanel();
    printPanel.setParentWindow(this);
    printPanel.setDatabase(database);//from  www  .j ava 2  s. co  m
    printPanel.setNotifier(notifier);
    printPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Print", null, printPanel, null, 1);

    resultsPanel = new ResultsPanel();
    resultsPanel.setParentWindow(this);
    resultsPanel.setDatabase(database);
    resultsPanel.setNotifier(notifier);
    resultsPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Results", null, resultsPanel, null, 1);

    competitionInterfacesPanel = new CompetitionInterfacesPanel();
    competitionInterfacesPanel.setParentWindow(this);
    competitionInterfacesPanel.setDatabase(database);
    competitionInterfacesPanel.setNotifier(notifier);
    competitionInterfacesPanel.setPeerManager(peerManager);
    competitionInterfacesPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Competition Interfaces", null, competitionInterfacesPanel, null, 1);

    sessionFightsPanel = new SessionFightsPanel();
    sessionFightsPanel.setParentWindow(this);
    sessionFightsPanel.setDatabase(database);
    sessionFightsPanel.setNotifier(notifier);
    sessionFightsPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Fight Order", null, sessionFightsPanel, null, 1);

    manageSessionsPanel = new ManageSessionsPanel();
    manageSessionsPanel.setParentWindow(this);
    manageSessionsPanel.setDatabase(database);
    manageSessionsPanel.setNotifier(notifier);
    manageSessionsPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Sessions", null, manageSessionsPanel, null, 1);

    fightOrderPanel = new FightOrderPanel();
    fightOrderPanel.setParentWindow(this);
    fightOrderPanel.setDatabase(database);
    fightOrderPanel.setNotifier(notifier);
    fightOrderPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Draw", null, fightOrderPanel, null, 1);

    managePoolsPanel = new ManageDivisionsPanel();
    managePoolsPanel.setParentWindow(this);
    managePoolsPanel.setDatabase(database);
    managePoolsPanel.setNotifier(notifier);
    managePoolsPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Divisions", null, managePoolsPanel, null, 1);

    managePlayersPanel = new ManagePlayersPanel();
    managePlayersPanel.setParentWindow(this);
    managePlayersPanel.setDatabase(database);
    managePlayersPanel.setNotifier(notifier);
    managePlayersPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Players", null, managePlayersPanel, null, 1);

    administrationPanel = new AdministrationPanel();
    administrationPanel.setParentWindow(this);
    administrationPanel.setDatabase(database);
    administrationPanel.setNotifier(notifier);
    administrationPanel.setLicenseManager(licenseManager);
    administrationPanel.afterPropertiesSet();

    mainTabbedPane.insertTab("Administration", null, administrationPanel, null, 1);

    ChatPanel chatPanel = new ChatPanel(peerManager);
    chatPanel.setBorder(new EmptyBorder(0, 0, 0, 0));

    javax.swing.GroupLayout chatPanelLayout = new javax.swing.GroupLayout(this.chatParentPanel);
    this.chatParentPanel.setLayout(chatPanelLayout);
    chatPanelLayout
            .setHorizontalGroup(chatPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chatPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    chatPanelLayout
            .setVerticalGroup(chatPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chatPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));

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

From source file:net.sf.vfsjfilechooser.plaf.metal.MetalVFSFileChooserUI.java

@SuppressWarnings("serial")
@Override// w w w.java 2  s.co  m
public void installComponents(VFSJFileChooser fc) {
    AbstractVFSFileSystemView fsv = fc.getFileSystemView();

    fc.setBorder(new EmptyBorder(12, 12, 11, 11));
    fc.setLayout(new BorderLayout(0, 11));

    filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor());
    fc.addPropertyChangeListener(filePane);

    updateUseShellFolder();

    // ********************************* //
    // **** Construct the top panel **** //
    // ********************************* //

    // Directory manipulation buttons
    JPanel topPanel = new JPanel(new BorderLayout(11, 0));
    topButtonPanel = new JPanel();
    topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
    topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);

    // Add the top panel to the fileChooser
    fc.add(topPanel, BorderLayout.NORTH);

    // ComboBox Label
    lookInLabel = new JLabel(lookInLabelText);
    topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);

    // CurrentDir ComboBox
    directoryComboBox = new JComboBox() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            // Must be small enough to not affect total width.
            d.width = 150;

            return d;
        }
    };
    directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
    directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    lookInLabel.setLabelFor(directoryComboBox);
    directoryComboBoxModel = createDirectoryComboBoxModel(fc);
    directoryComboBox.setModel(directoryComboBoxModel);
    directoryComboBox.addActionListener(directoryComboBoxAction);
    directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
    directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
    directoryComboBox.setMaximumRowCount(8);

    topPanel.add(directoryComboBox, BorderLayout.CENTER);

    // Up Button
    upFolderButton = new JButton(getChangeToParentDirectoryAction());
    upFolderButton.setText(null);
    upFolderButton.setIcon(upFolderIcon);
    upFolderButton.setToolTipText(upFolderToolTipText);
    upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName);
    upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    upFolderButton.setMargin(shrinkwrap);

    topButtonPanel.add(upFolderButton);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // Home Button
    FileObject homeDir = fsv.getHomeDirectory();
    String toolTipText = homeFolderToolTipText;

    if (fsv.isRoot(homeDir)) {
        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
    }

    JButton b = new JButton(homeFolderIcon);
    b.setToolTipText(toolTipText);
    b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName);
    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    b.setMargin(shrinkwrap);

    b.addActionListener(getGoHomeAction());
    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // New Directory Button
    if (!UIManager.getBoolean("FileChooser.readOnly")) {
        b = new JButton(filePane.getNewFolderAction());
        b.setText(null);
        b.setIcon(newFolderIcon);
        b.setToolTipText(newFolderToolTipText);
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName);
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        b.setMargin(shrinkwrap);
    }

    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // View button group
    ButtonGroup viewButtonGroup = new ButtonGroup();

    // List Button
    listViewButton = new JToggleButton(listViewIcon);
    listViewButton.setToolTipText(listViewButtonToolTipText);
    listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
    listViewButton.setSelected(true);
    listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    listViewButton.setMargin(shrinkwrap);
    listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST));
    topButtonPanel.add(listViewButton);
    viewButtonGroup.add(listViewButton);

    // Details Button
    detailsViewButton = new JToggleButton(detailsViewIcon);
    detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
    detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
            detailsViewButtonAccessibleName);
    detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    detailsViewButton.setMargin(shrinkwrap);
    detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS));
    topButtonPanel.add(detailsViewButton);
    viewButtonGroup.add(detailsViewButton);
    filePane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if ("viewType".equals(e.getPropertyName())) {
                final int viewType = filePane.getViewType();

                if (viewType == VFSFilePane.VIEWTYPE_LIST) {
                    listViewButton.setSelected(true);
                } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) {
                    detailsViewButton.setSelected(true);
                }
            }
        }
    });

    // ************************************** //
    // ******* Add the directory pane ******* //
    // ************************************** //
    fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);

    JComponent accessory = fc.getAccessory();

    if (accessory != null) {
        getAccessoryPanel().add(accessory);
    }

    filePane.setPreferredSize(LIST_PREF_SIZE);
    fc.add(filePane, BorderLayout.CENTER);

    // ********************************** //
    // **** Construct the bottom panel ** //
    // ********************************** //
    bottomPanel = getBottomPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
    fc.add(bottomPanel, BorderLayout.SOUTH);

    // FileName label and textfield
    JPanel fileNamePanel = new JPanel();
    fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(fileNamePanel);
    bottomPanel.add(Box.createRigidArea(vstrut5));

    fileNameLabel = new AlignedLabel();
    populateFileNameLabel();
    fileNamePanel.add(fileNameLabel);

    fileNameTextField = new JTextField(35) {
        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };

    PopupHandler.installDefaultMouseListener(fileNameTextField);

    fileNamePanel.add(fileNameTextField);
    fileNameLabel.setLabelFor(fileNameTextField);
    fileNameTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                filePane.clearSelection();
            }
        }
    });

    if (fc.isMultiSelectionEnabled()) {
        setFileName(fileNameString(fc.getSelectedFiles()));
    } else {
        setFileName(fileNameString(fc.getSelectedFile()));
    }

    // Filetype label and combobox
    JPanel filesOfTypePanel = new JPanel();
    filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(filesOfTypePanel);

    AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
    filesOfTypePanel.add(filesOfTypeLabel);

    filterComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterComboBoxModel);
    filterComboBox = new JComboBox(filterComboBoxModel);
    filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText);
    filesOfTypeLabel.setLabelFor(filterComboBox);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    filesOfTypePanel.add(filterComboBox);

    // buttons
    getButtonPanel().setLayout(new ButtonAreaLayout());

    approveButton = new JButton(getApproveButtonText(fc));
    // Note: Metal does not use mnemonics for approve and cancel
    approveButton.addActionListener(getApproveSelectionAction());
    fileNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                getApproveSelectionAction().actionPerformed(null);
            }
        }
    });
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    getButtonPanel().add(approveButton);

    cancelButton = new JButton(cancelButtonText);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    cancelButton.addActionListener(getCancelSelectionAction());
    getButtonPanel().add(cancelButton);

    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }

    groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}

From source file:com.haulmont.cuba.desktop.sys.vcl.CollapsiblePanel.java

public void setBorderVisible(boolean borderVisible) {
    this.borderVisible = borderVisible;
    if (borderVisible) {
        setBorder(createBorderImplementation());
        placeTitleComponent();/*w w  w .  j  a v a2s  . com*/
    } else {
        if (titleBtn.isVisible()) {
            this.setBorder(new EmptyBorder(12, 2, 2, 2));
        } else {
            this.setBorder(new EmptyBorder(0, 0, 0, 0));
        }
        placeTitleComponent();
    }
    this.repaint();
}

From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java

@SuppressWarnings("serial")
@Override//from w  w  w  .j av a  2  s.  c  o m
public void installComponents(VFSJFileChooser fc) {
    AbstractVFSFileSystemView fsv = fc.getFileSystemView();

    fc.setBorder(new EmptyBorder(12, 12, 11, 11));
    fc.setLayout(new BorderLayout(0, 11));

    filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor());
    fc.addPropertyChangeListener(filePane);

    updateUseShellFolder();

    // ********************************* //
    // **** Construct the top panel **** //
    // ********************************* //

    // Directory manipulation buttons
    JPanel topPanel = new JPanel(new BorderLayout(11, 0));
    topButtonPanel = new JPanel();
    topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
    topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);

    // Add the top panel to the fileChooser
    fc.add(topPanel, BorderLayout.NORTH);

    // ComboBox Label
    lookInLabel = new JLabel(lookInLabelText);
    topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);

    // CurrentDir ComboBox
    directoryComboBox = new JComboBox() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            // Must be small enough to not affect total width.
            d.width = 150;

            return d;
        }
    };
    directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
    directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    lookInLabel.setLabelFor(directoryComboBox);
    directoryComboBoxModel = createDirectoryComboBoxModel(fc);
    directoryComboBox.setModel(directoryComboBoxModel);
    directoryComboBox.addActionListener(directoryComboBoxAction);
    directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
    directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
    directoryComboBox.setMaximumRowCount(8);

    topPanel.add(directoryComboBox, BorderLayout.CENTER);

    // Up Button
    upFolderButton = new JButton(getChangeToParentDirectoryAction());
    upFolderButton.setText(null);
    upFolderButton.setIcon(upFolderIcon);
    upFolderButton.setToolTipText(upFolderToolTipText);
    upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName);
    upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    upFolderButton.setMargin(shrinkwrap);

    topButtonPanel.add(upFolderButton);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // Home Button
    FileObject homeDir = fsv.getHomeDirectory();
    String toolTipText = homeFolderToolTipText;

    if (fsv.isRoot(homeDir)) {
        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
    }

    JButton b = new JButton(homeFolderIcon);
    b.setToolTipText(toolTipText);
    b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName);
    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    b.setMargin(shrinkwrap);

    b.addActionListener(getGoHomeAction());
    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // New Directory Button
    if (!UIManager.getBoolean("FileChooser.readOnly")) {
        b = new JButton(filePane.getNewFolderAction());
        b.setText(null);
        b.setIcon(newFolderIcon);
        b.setToolTipText(newFolderToolTipText);
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName);
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        b.setMargin(shrinkwrap);
    }

    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // View button group
    ButtonGroup viewButtonGroup = new ButtonGroup();

    // List Button
    listViewButton = new JToggleButton(listViewIcon);
    listViewButton.setToolTipText(listViewButtonToolTipText);
    listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
    listViewButton.setSelected(true);
    listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    listViewButton.setMargin(shrinkwrap);
    listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST));
    topButtonPanel.add(listViewButton);
    viewButtonGroup.add(listViewButton);

    // Details Button
    detailsViewButton = new JToggleButton(detailsViewIcon);
    detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
    detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
            detailsViewButtonAccessibleName);
    detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    detailsViewButton.setMargin(shrinkwrap);
    detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS));
    topButtonPanel.add(detailsViewButton);
    viewButtonGroup.add(detailsViewButton);
    filePane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if ("viewType".equals(e.getPropertyName())) {
                final int viewType = filePane.getViewType();

                if (viewType == VFSFilePane.VIEWTYPE_LIST) {
                    listViewButton.setSelected(true);
                } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) {
                    detailsViewButton.setSelected(true);
                }
            }
        }
    });

    // ************************************** //
    // ******* Add the directory pane ******* //
    // ************************************** //
    fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);

    JComponent accessory = fc.getAccessory();

    if (accessory != null) {
        getAccessoryPanel().add(accessory);
    }

    filePane.setPreferredSize(LIST_PREF_SIZE);
    fc.add(filePane, BorderLayout.CENTER);

    // ********************************** //
    // **** Construct the bottom panel ** //
    // ********************************** //
    bottomPanel = getBottomPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
    fc.add(bottomPanel, BorderLayout.SOUTH);

    // FileName label and textfield
    JPanel fileNamePanel = new JPanel();
    fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(fileNamePanel);
    bottomPanel.add(Box.createRigidArea(vstrut5));

    fileNameLabel = new AlignedLabel();
    populateFileNameLabel();
    fileNamePanel.add(fileNameLabel);

    fileNameTextField = new JTextField(35) {
        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };

    PopupHandler.installDefaultMouseListener(fileNameTextField);

    fileNamePanel.add(fileNameTextField);
    fileNameLabel.setLabelFor(fileNameTextField);
    fileNameTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                filePane.clearSelection();
            }
        }
    });

    if (fc.isMultiSelectionEnabled()) {
        setFileName(fileNameString(fc.getSelectedFileObjects()));
    } else {
        setFileName(fileNameString(fc.getSelectedFileObject()));
    }

    // Filetype label and combobox
    JPanel filesOfTypePanel = new JPanel();
    filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(filesOfTypePanel);

    AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
    filesOfTypePanel.add(filesOfTypeLabel);

    filterComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterComboBoxModel);
    filterComboBox = new JComboBox(filterComboBoxModel);
    filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText);
    filesOfTypeLabel.setLabelFor(filterComboBox);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    filesOfTypePanel.add(filterComboBox);

    // buttons
    getButtonPanel().setLayout(new ButtonAreaLayout());

    approveButton = new JButton(getApproveButtonText(fc));
    // Note: Metal does not use mnemonics for approve and cancel
    approveButton.addActionListener(getApproveSelectionAction());
    fileNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                getApproveSelectionAction().actionPerformed(null);
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                getFileChooser().cancelSelection();
            }
        }
    });
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    getButtonPanel().add(approveButton);

    cancelButton = new JButton(cancelButtonText);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    cancelButton.addActionListener(getCancelSelectionAction());
    getButtonPanel().add(cancelButton);

    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }

    groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}

From source file:com.titan.mainframe.MainFrame.java

public MainFrame() {
    String osName = System.getProperty("os.name").toLowerCase();
    if (osName.toLowerCase().contains("mac")) {
        com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication();
        macApp.addApplicationListener(this);
    }//from   w w w  .  ja  v a 2 s  . c  om
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            handleQuit();
        }

        @Override
        public void windowOpened(WindowEvent e) {
            windowOpened = true;
        }
    });
    setTitle("Titan " + Global.version);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    if (TitanSetting.getInstance().width == 0 || TitanSetting.getInstance().height == 0) {
        setBounds(TitanSetting.getInstance().x, TitanSetting.getInstance().y, 1200, 700);
    } else {
        setBounds(TitanSetting.getInstance().x, TitanSetting.getInstance().y, TitanSetting.getInstance().width,
                TitanSetting.getInstance().height);
    }

    setIconImage(new ImageIcon(getClass().getClassLoader().getResource("com/titan/image/titan_icon.png"))
            .getImage());

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(0, 0));
    splitPane.setDividerLocation(TitanSetting.getInstance().mainframeDivX);
    contentPane.add(splitPane, BorderLayout.CENTER);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout(0, 0));

    JLabel logoLabel = new JLabel();
    logoLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            mainContentPanel.removeAll();
            mainContentPanel.add(welcomePanel, BorderLayout.CENTER);
            mainContentPanel.updateUI();
        }
    });

    //      try {
    //         BufferedImage b = ImageIO.read(MainFrame.class.getResource("/com/titan/image/titanLogo.png"));
    //         Image i = b.getScaledInstance((int) (b.getWidth() * 0.6), (int) (b.getHeight() * 0.6), Image.SCALE_SMOOTH);
    logoLabel.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/titanLogo.png")));
    //      } catch (IOException e1) {
    //         e1.printStackTrace();
    //      }
    //      logoLabel.setMaximumSize(new Dimension(150, 150));

    JPanel controlPanel = new JPanel();
    controlPanel.setBackground(new Color(239, 249, 255));
    controlPanel.setOpaque(true);
    panel.add(controlPanel, BorderLayout.CENTER);
    controlPanel.setLayout(new BorderLayout());

    JScrollPane computeScrollPane = new JScrollPane();
    tabbedPane.addTab("Compute", computeScrollPane);
    controlPanel.add(tabbedPane, BorderLayout.CENTER);

    serverTree = new JTree();
    serverTree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            //            Object obj = mainContentPanel.getComponent(0);
            //            if (obj instanceof VMMainPanel) {
            //               ((MainPanel) obj).refresh();
            //            }
        }
    });
    serverTree.setModel(computeTreeModel);
    serverTree.setCellRenderer(new ZoneTreeRenderer());
    serverTree.setRootVisible(false);
    computeScrollPane.setViewportView(serverTree);
    updateComputeTree();

    JScrollPane zoneScrollPane = new JScrollPane();
    tabbedPane.addTab("Zone", zoneScrollPane);

    zoneTree = new JTree();
    zoneTree.setModel(zoneTreeModel);
    zoneTree.setCellRenderer(new ZoneTreeRenderer());
    zoneScrollPane.setViewportView(zoneTree);
    updateZoneTree();
    splitPane.setLeftComponent(panel);

    splitPane.setRightComponent(mainContentPanel);
    mainContentPanel.setLayout(new BorderLayout(0, 0));

    welcomePanel = new WelcomePanel();
    mainContentPanel.add(welcomePanel, BorderLayout.CENTER);
    welcomePanel.setLayout(new BorderLayout(0, 0));
    welcomePanel.add(mainScreenLabel, BorderLayout.CENTER);
    mainScreenLabel.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/mainscreen.png")));

    JPanel panel_1 = new JPanel();
    welcomePanel.add(panel_1, BorderLayout.SOUTH);

    JButton licenseButton = new JButton("License");
    licenseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            InputStream in = MainFrame.class.getResourceAsStream("/com/titan/license.txt");
            try {
                LicenseDialog dialog = new LicenseDialog(MainFrame.this, IOUtils.toString(in));
                CommonLib.centerDialog(dialog);
                dialog.setVisible(true);
            } catch (IOException e1) {
                e1.printStackTrace();
            } finally {
                IOUtils.closeQuietly(in);
            }
        }
    });
    panel_1.add(licenseButton);

    ribbonPanel = new JPanel();
    contentPane.add(ribbonPanel, BorderLayout.NORTH);
    ribbonPanel.setLayout(new BorderLayout(0, 0));

    ribbonTabbedPane = new JTabbedPane(JTabbedPane.TOP);
    ribbonTabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            //            if (!windowOpened) {
            //               return;
            //            }
            String tab = ribbonTabbedPane.getTitleAt(ribbonTabbedPane.getSelectedIndex());
            if (tab.equals("Server")) {
                if (mainServerPanel == null || !mainServerPanel.serverPanel.jprogressBarDialog.isActive()) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            mainContentPanel.removeAll();
                            mainServerPanel = new MainServerPanel(MainFrame.this);
                            mainContentPanel.add(mainServerPanel, BorderLayout.CENTER);
                            mainContentPanel.updateUI();
                        }
                    });
                }
            } else if (tab.equals("VM")) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        mainContentPanel.removeAll();
                        mainContentPanel.add(new VMMainPanel(MainFrame.this), BorderLayout.CENTER);
                        mainContentPanel.updateUI();
                    }
                });
            } else if (tab.equals("Keystone")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new KeystonePanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            } else if (tab.equals("Flavor")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new FlavorPanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            } else if (tab.equals("Storage")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new StoragePanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            } else if (tab.equals("Network")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new SDNPanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            } else if (tab.equals("Setting")) {
                mainContentPanel.removeAll();
                mainContentPanel.add(new SettingPanel(MainFrame.this), BorderLayout.CENTER);
                mainContentPanel.updateUI();
            }
        }
    });
    ribbonTabbedPane.putClientProperty("type", "ribbonType");
    ribbonTabbedPane.setPreferredSize(new Dimension(1000, 140));
    ribbonPanel.add(ribbonTabbedPane, BorderLayout.CENTER);

    serverPanel = new JRibbonPanel();
    serverPanel.setLayout(new MigLayout("", "[][][][][][][][][][][][][][grow][]", "[grow][grow][]"));
    ribbonTabbedPane.addTab("Server", null, serverPanel, null);

    logoutButton = new JRibbonBigButton("Logout");
    logoutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            logout();
        }
    });

    rbnbgbtnAddServer = new JRibbonBigButton();
    rbnbgbtnAddServer.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    rbnbgbtnAddServer.setText("Add Server");
    serverPanel.add(rbnbgbtnAddServer, "cell 0 0 1 3,growy");

    rbnbgbtnDeleteServer = new JRibbonBigButton();
    rbnbgbtnDeleteServer
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png")));
    rbnbgbtnDeleteServer.setText("Delete Server");
    serverPanel.add(rbnbgbtnDeleteServer, "cell 1 0 1 3,growy");
    logoutButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/logout.png")));
    logoutButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    logoutButton.setHorizontalTextPosition(SwingConstants.CENTER);
    serverPanel.add(logoutButton, "cell 14 0 1 3,growy");

    vmPanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("VM", null, vmPanel, null);
    vmPanel.setLayout(new MigLayout("", "[][][][][][][][][][][][][][][grow][]", "[grow][grow][]"));

    launchButton = new JRibbonBigButton("Launch");
    launchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new LaunchInstanceDialog(MainFrame.this).setVisible(true);
        }
    });
    launchButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/launch.png")));
    launchButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    launchButton.setHorizontalTextPosition(SwingConstants.CENTER);
    vmPanel.add(launchButton, "cell 0 0 1 3,growy");

    pauseButton = new JRibbonButton("Pause");
    pauseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova pause");
        }
    });
    pauseButton.setHorizontalAlignment(SwingConstants.LEFT);
    pauseButton.setIcon(
            new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/control_pause.png")));
    vmPanel.add(pauseButton, "cell 2 0,growx");

    stopButton = new JRibbonButton("Stop");
    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova stop");
        }
    });
    stopButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/stop.png")));
    stopButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    stopButton.setHorizontalTextPosition(SwingConstants.CENTER);
    vmPanel.add(stopButton, "cell 1 0 1 3,growy");

    unpauseButton = new JRibbonButton("Unpause");
    unpauseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova unpause");
        }
    });
    unpauseButton.setHorizontalAlignment(SwingConstants.LEFT);
    unpauseButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/control_play.png")));

    suspendButton = new JRibbonButton("Suspend");
    suspendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova suspend");
        }
    });
    suspendButton.setHorizontalAlignment(SwingConstants.LEFT);
    suspendButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/disk.png")));
    vmPanel.add(suspendButton, "cell 3 0,growx");

    softRebootButton = new JRibbonButton("Soft reboot");
    softRebootButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova soft-reboot");
        }
    });
    softRebootButton.setHorizontalAlignment(SwingConstants.LEFT);
    softRebootButton.setIcon(new ImageIcon(
            MainFrame.class.getResource("/com/titan/image/famfamfam/arrow_rotate_clockwise.png")));

    selectAllVMButton = new JRibbonButton("Select all");
    selectAllVMButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.selectAll();
        }
    });
    vmPanel.add(selectAllVMButton, "cell 4 0,growx");
    vmPanel.add(softRebootButton, "cell 9 0,growx");

    createMacroButton = new JRibbonButton("Create macro");
    createMacroButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png")));
    createMacroButton.setHorizontalAlignment(SwingConstants.LEFT);

    setGroupNameButton = new JRibbonButton("Set group name");
    setGroupNameButton.setHorizontalAlignment(SwingConstants.LEFT);
    setGroupNameButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.setGroupName();
        }
    });
    vmPanel.add(setGroupNameButton, "cell 10 0");
    vmPanel.add(createMacroButton, "cell 13 0,growx");

    ribbonSeparator_3 = new JRibbonSeparator();
    vmPanel.add(ribbonSeparator_3, "cell 14 0 1 3,growy");
    vmPanel.add(unpauseButton, "cell 2 1,growx");

    remoteButton = new JRibbonButton("Remote");
    remoteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.remote();
        }
    });
    remoteButton.setHorizontalAlignment(SwingConstants.LEFT);
    remoteButton.setIcon(new ImageIcon(
            MainFrame.class.getResource("/com/titan/image/famfamfam/application_osx_terminal.png")));

    unselectAllButton = new JRibbonButton("Unselect all");
    unselectAllButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.unselectAll();
        }
    });
    vmPanel.add(unselectAllButton, "cell 4 1,growx");
    vmPanel.add(remoteButton, "cell 2 2,growx");

    performanceMeterButton = new JRibbonButton("Performance meter");
    performanceMeterButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/chart_curve.png")));
    performanceMeterButton.setHorizontalAlignment(SwingConstants.LEFT);
    vmPanel.add(performanceMeterButton, "cell 13 1,growx");

    resumeButton = new JRibbonButton("Resume");
    resumeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova resume");
        }
    });
    resumeButton.setHorizontalAlignment(SwingConstants.LEFT);
    resumeButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/drive_disk.png")));
    vmPanel.add(resumeButton, "cell 3 1,growx");

    deleteButton = new JRibbonBigButton("Delete");
    deleteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova delete");
        }
    });
    vmPanel.add(deleteButton, "cell 7 0 1 3,alignx center,growy");
    deleteButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png")));
    deleteButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    deleteButton.setHorizontalTextPosition(SwingConstants.CENTER);

    logButton = new JRibbonBigButton("Log");
    logButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.log();
        }
    });
    vmPanel.add(logButton, "cell 6 0 1 3,alignx center,growy");
    logButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/log.png")));
    logButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    logButton.setHorizontalTextPosition(SwingConstants.CENTER);

    hardRebootButton = new JRibbonButton("Hard reboot");
    hardRebootButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0);
            vmMainPanel.action("from titan: nova hard-reboot");
        }
    });
    hardRebootButton.setHorizontalAlignment(SwingConstants.LEFT);
    hardRebootButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/arrow_undo.png")));

    ribbonSeparator = new JRibbonSeparator();
    vmPanel.add(ribbonSeparator, "cell 5 0 1 3,alignx center,growy");

    ribbonSeparator_1 = new JRibbonSeparator();
    vmPanel.add(ribbonSeparator_1, "cell 8 0 1 3,alignx center,growy");
    vmPanel.add(hardRebootButton, "cell 9 1,growx");

    ribbonSeparator_2 = new JRibbonSeparator();
    vmPanel.add(ribbonSeparator_2, "cell 11 0 1 3,grow");

    macroButton = new JRibbonBigButton("Macro");
    macroButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/code.png")));
    macroButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    macroButton.setHorizontalTextPosition(SwingConstants.CENTER);
    vmPanel.add(macroButton, "cell 12 0 1 3,growy");

    snapshotButton = new JRibbonButton("Snapshot");
    snapshotButton.setHorizontalAlignment(SwingConstants.LEFT);
    snapshotButton.setIcon(
            new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/application_cascade.png")));
    vmPanel.add(snapshotButton, "cell 3 2,growx");

    advanceButton = new JRibbonButton("Advance");
    advanceButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    advanceButton.setHorizontalAlignment(SwingConstants.LEFT);
    advanceButton.setIcon(new ImageIcon(
            MainFrame.class.getResource("/com/titan/image/famfamfam/application_view_detail.png")));
    vmPanel.add(advanceButton, "cell 9 2,growx");

    executionMapButton = new JRibbonButton("Execution map");
    executionMapButton.setIcon(
            new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/chart_organisation.png")));
    executionMapButton.setHorizontalAlignment(SwingConstants.LEFT);
    vmPanel.add(executionMapButton, "cell 13 2,growx");

    keystonePanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Keystone", null, keystonePanel, null);
    keystonePanel.setLayout(new MigLayout("", "[][][][][][][][][][]", "[grow][][][][]"));

    addUserButton = new JRibbonBigButton("Add user");
    addUserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.addUser();
        }
    });
    addUserButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    addUserButton.setHorizontalTextPosition(SwingConstants.CENTER);
    addUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/addUser.png")));
    keystonePanel.add(addUserButton, "cell 0 0 1 3,growy");

    editUserButton = new JRibbonButton("Edit user");
    editUserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    editUserButton.setHorizontalAlignment(SwingConstants.LEFT);
    editUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png")));
    keystonePanel.add(editUserButton, "cell 1 0,growx");

    changePasswordButton = new JRibbonButton("Change password");
    keystonePanel.add(changePasswordButton, "cell 2 0");

    ribbonSeparator_4 = new JRibbonSeparator();
    keystonePanel.add(ribbonSeparator_4, "cell 3 0 1 3,growy");

    addRoleButton = new JRibbonBigButton("Add role");
    addRoleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.addRole();
        }
    });
    addRoleButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    addRoleButton.setHorizontalTextPosition(SwingConstants.CENTER);
    addRoleButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/addRole.png")));
    keystonePanel.add(addRoleButton, "cell 4 0 1 3,growy");

    deleteUserButton = new JRibbonButton("Delete user");
    deleteUserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    deleteUserButton.setHorizontalAlignment(SwingConstants.LEFT);
    deleteUserButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));

    editRoleButton = new JRibbonButton("Edit role");
    editRoleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
        }
    });
    editRoleButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png")));
    editRoleButton.setHorizontalAlignment(SwingConstants.LEFT);
    keystonePanel.add(editRoleButton, "cell 5 0,growx");

    ribbonSeparator_5 = new JRibbonSeparator();
    keystonePanel.add(ribbonSeparator_5, "cell 6 0 1 3,growy");

    createTenantButton = new JRibbonBigButton("Create tenant");
    createTenantButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.createTenant();
        }
    });
    createTenantButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    createTenantButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    createTenantButton.setHorizontalTextPosition(SwingConstants.CENTER);
    keystonePanel.add(createTenantButton, "cell 7 0 1 3,growy");

    deleteTenantButton = new JRibbonBigButton("Delete tenant");
    deleteTenantButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.deleteTenant();
        }
    });
    deleteTenantButton
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png")));
    deleteTenantButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    deleteTenantButton.setHorizontalTextPosition(SwingConstants.CENTER);
    keystonePanel.add(deleteTenantButton, "cell 8 0 1 3,growy");
    keystonePanel.add(deleteUserButton, "cell 1 1,growx");

    detailUserButton = new JRibbonButton("Detail user");
    detailUserButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.showUserDetail();
        }
    });
    detailUserButton.setHorizontalAlignment(SwingConstants.LEFT);
    detailUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/zoom.png")));
    keystonePanel.add(detailUserButton, "cell 1 2,growx");

    btnDeleteRole = new JRibbonButton("Delete role");
    btnDeleteRole.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.deleteRole();
        }
    });
    btnDeleteRole.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    keystonePanel.add(btnDeleteRole, "cell 5 1,growx");

    assignRoleButton = new JRibbonButton("Assign role");
    assignRoleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0);
            keystonePanel.assignRole();
        }
    });
    assignRoleButton.setSelectedIcon(
            new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/user_add.png")));
    keystonePanel.add(assignRoleButton, "cell 5 2,growx");

    lblUser = new JRibbonLabel("user");
    keystonePanel.add(lblUser, "cell 0 3 2 1,growx");

    rbnlblRole = new JRibbonLabel("role");
    keystonePanel.add(rbnlblRole, "cell 4 3 2 1,growx");

    rbnlblTenant = new JRibbonLabel();
    rbnlblTenant.setText("tenant");
    keystonePanel.add(rbnlblTenant, "cell 7 3 2 1,growx");

    flavorPanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Flavor", null, flavorPanel, null);
    flavorPanel.setLayout(new MigLayout("", "[][]", "[grow][][][]"));

    rbnbgbtnCreateFlavor = new JRibbonBigButton();
    rbnbgbtnCreateFlavor.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    rbnbgbtnCreateFlavor.setText("Create Flavor");
    flavorPanel.add(rbnbgbtnCreateFlavor, "cell 0 0 1 3,growy");

    btnDeleteFlavor = new JRibbonBigButton("Delete Flavor");
    btnDeleteFlavor.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png")));
    flavorPanel.add(btnDeleteFlavor, "cell 1 0 1 3,growy");

    storagePanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Storage", null, storagePanel, null);
    storagePanel.setLayout(new MigLayout("", "[][][][][][]", "[grow][][][]"));

    uploadImageButton = new JRibbonBigButton("Upload");
    uploadImageButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    uploadImageButton.setVerticalTextPosition(SwingConstants.BOTTOM);
    uploadImageButton.setHorizontalTextPosition(SwingConstants.CENTER);
    storagePanel.add(uploadImageButton, "cell 0 0 1 3, growy");

    btnDelete = new JRibbonButton("Delete");
    btnDelete.setHorizontalAlignment(SwingConstants.LEFT);
    btnDelete.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    storagePanel.add(btnDelete, "cell 1 0,growx");

    ribbonSeparator_6 = new JRibbonSeparator();
    storagePanel.add(ribbonSeparator_6, "cell 2 0 1 3,grow");

    btnCreateVolume = new JRibbonBigButton("Create volume");
    btnCreateVolume.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png")));
    btnCreateVolume.setVerticalTextPosition(SwingConstants.BOTTOM);
    btnCreateVolume.setHorizontalTextPosition(SwingConstants.CENTER);
    storagePanel.add(btnCreateVolume, "cell 3 0 1 3,growy");

    btnDelete_1 = new JRibbonButton("Delete");
    btnDelete_1.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    btnDelete_1.setHorizontalAlignment(SwingConstants.LEFT);
    storagePanel.add(btnDelete_1, "cell 4 0,growx");

    btnAttach = new JRibbonButton("Attach to vm");
    btnAttach.setHorizontalAlignment(SwingConstants.LEFT);
    btnAttach.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/attach.png")));
    storagePanel.add(btnAttach, "cell 5 0,growx");

    btnChangeName = new JRibbonButton("Change name");
    btnChangeName.setHorizontalAlignment(SwingConstants.LEFT);
    btnChangeName.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png")));
    storagePanel.add(btnChangeName, "cell 1 1,growx");

    btnDetail = new JRibbonButton("Detail");
    btnDetail.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/zoom.png")));
    btnDetail.setHorizontalAlignment(SwingConstants.LEFT);
    storagePanel.add(btnDetail, "cell 4 1,growx");

    btnDetachToVm = new JRibbonButton("Detach to vm");
    btnDetachToVm.setHorizontalAlignment(SwingConstants.LEFT);
    btnDetachToVm.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/delete.png")));
    storagePanel.add(btnDetachToVm, "cell 5 1,growx");

    btnPublicprivate = new JRibbonButton("public/private");
    btnPublicprivate.setHorizontalAlignment(SwingConstants.LEFT);
    btnPublicprivate.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/tick.png")));
    storagePanel.add(btnPublicprivate, "cell 1 2,growx");

    btnAddVolumeType = new JRibbonButton("Add volume type");
    btnAddVolumeType.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png")));
    btnAddVolumeType.setHorizontalAlignment(SwingConstants.LEFT);
    storagePanel.add(btnAddVolumeType, "cell 4 2");

    btnDeleteVolumeType = new JRibbonButton("Delete volume type");
    btnDeleteVolumeType
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    btnDeleteVolumeType.setHorizontalAlignment(SwingConstants.LEFT);
    storagePanel.add(btnDeleteVolumeType, "cell 5 2");

    rbnlblImage = new JRibbonLabel();
    rbnlblImage.setText("Image");
    storagePanel.add(rbnlblImage, "cell 0 3 2 1,growx");

    rbnlblVolume = new JRibbonLabel();
    rbnlblVolume.setText("Volume");
    storagePanel.add(rbnlblVolume, "cell 3 3 3 1,growx");

    networkPanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Network", null, networkPanel, null);

    settingPanel = new JRibbonPanel();
    ribbonTabbedPane.addTab("Setting", null, settingPanel, null);
    settingPanel.setLayout(new MigLayout("", "[][][]", "[grow][grow][]"));

    rbnbgbtnSystemSetting = new JRibbonBigButton();
    rbnbgbtnSystemSetting
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/systemSetting.png")));
    rbnbgbtnSystemSetting.setText("System Setting");
    settingPanel.add(rbnbgbtnSystemSetting, "cell 0 0 1 3,growy");

    rbnbgbtnDatabase = new JRibbonBigButton();
    rbnbgbtnDatabase
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/database.png")));
    rbnbgbtnDatabase.setText("Database");
    settingPanel.add(rbnbgbtnDatabase, "cell 1 0 1 3,growy");

    rbnbtnAddGroup = new JRibbonButton();
    rbnbtnAddGroup.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png")));
    rbnbtnAddGroup.setText("Add Group");
    settingPanel.add(rbnbtnAddGroup, "cell 2 0");

    rbnbtnEditGroup = new JRibbonButton();
    rbnbtnEditGroup
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png")));
    rbnbtnEditGroup.setText("Edit Group");
    settingPanel.add(rbnbtnEditGroup, "cell 2 1");

    rbnbtnDeleteGroup = new JRibbonButton();
    rbnbtnDeleteGroup
            .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png")));
    rbnbtnDeleteGroup.setText("Delete Group");
    settingPanel.add(rbnbtnDeleteGroup, "cell 2 2");

    logoPanel = new JRibbonPanel();
    ribbonPanel.add(logoPanel, BorderLayout.WEST);
    logoPanel.setLayout(new BorderLayout(0, 0));
    logoPanel.add(logoLabel, BorderLayout.CENTER);

    setLocationRelativeTo(null);

    new Thread(new TitanServerUpdateThread()).start();
}