Example usage for javax.swing JTextArea setEditable

List of usage examples for javax.swing JTextArea setEditable

Introduction

In this page you can find the example usage for javax.swing JTextArea setEditable.

Prototype

@BeanProperty(description = "specifies if the text can be edited")
public void setEditable(boolean b) 

Source Link

Document

Sets the specified boolean to indicate whether or not this TextComponent should be editable.

Usage

From source file:util.ui.UiUtilities.java

/**
 * Creates a text area that holds a help text.
 *
 * @param msg/*from w w  w .j a v  a  2  s . c om*/
 *          The help text.
 * @return A text area containing the help text.
 */
public static JTextArea createHelpTextArea(String msg) {
    JTextArea descTA = new JTextArea(msg);
    descTA.setBorder(BorderFactory.createEmptyBorder());
    descTA.setFont(new JLabel().getFont());
    descTA.setEditable(false);
    descTA.setOpaque(false);
    descTA.setWrapStyleWord(true);
    descTA.setLineWrap(true);
    descTA.setFocusable(false);

    Color bg = new JPanel().getBackground();

    descTA.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));

    return descTA;
}

From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java

private JMenu createShortMenu() {
    JMenu shortMenu = new JMenu();
    addDarkModeCallback(b -> {/*from  w  w  w  . j  a va  2  s . c o  m*/
        shortMenu.setBackground(b ? OPENBST_BLUE.darker().darker() : OPENBST_BLUE.brighter());
        shortMenu.setForeground(b ? Color.WHITE : OPENBST_BLUE);
    });
    shortMenu.setBackground(OPENBST_BLUE.brighter());
    shortMenu.setForeground(OPENBST_BLUE);
    shortMenu.setText(Lang.get("banner.title"));
    shortMenu.setIcon(new ImageIcon(Icons.getImage("Logo", 16)));
    JMenuItem label = new JMenuItem(Lang.get("menu.title"));
    label.setEnabled(false);
    shortMenu.add(label);
    shortMenu.addSeparator();
    shortMenu.add(
            new JMenuItem(new AbstractAction(Lang.get("menu.open"), new ImageIcon(Icons.getImage("Open", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    openStory(VisualsUtils.askForFile(OpenBSTGUI.this, Lang.get("file.title")));
                }
            }));

    shortMenu.addSeparator();

    shortMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.create"), new ImageIcon(Icons.getImage("Add Property", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    doNewEditor();
                }
            }));

    JMenu additionalMenu = new JMenu(Lang.get("menu.advanced"));
    shortMenu.add(additionalMenu);

    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.package"), new ImageIcon(Icons.getImage("Open Archive", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    new PackageDialog(instance).setVisible(true);
                }
            }));
    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("langcheck"), new ImageIcon(Icons.getImage("LangCheck", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    final Map<String, String> languages = new Gson()
                            .fromJson(new InputStreamReader(
                                    OpenBST.class.getResourceAsStream(
                                            "/utybo/branchingstorytree/swing/lang/langs.json"),
                                    StandardCharsets.UTF_8), new TypeToken<Map<String, String>>() {
                                    }.getType());
                    languages.remove("en");
                    languages.remove("default");
                    JComboBox<String> jcb = new JComboBox<>(new Vector<>(languages.keySet()));
                    JPanel panel = new JPanel();
                    panel.add(new JLabel(Lang.get("langcheck.choose")));
                    panel.add(jcb);
                    int result = JOptionPane.showOptionDialog(OpenBSTGUI.this, panel, Lang.get("langcheck"),
                            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
                    if (result == JOptionPane.OK_OPTION) {
                        Locale selected = new Locale((String) jcb.getSelectedItem());
                        if (!Lang.getMap().keySet().contains(selected)) {
                            try {
                                Lang.loadTranslationsFromFile(selected,
                                        OpenBST.class
                                                .getResourceAsStream("/utybo/branchingstorytree/swing/lang/"
                                                        + languages.get(jcb.getSelectedItem().toString())));
                            } catch (UnrespectedModelException | IOException e1) {
                                LOG.warn("Failed to load translation file", e1);
                            }
                        }
                        ArrayList<String> list = new ArrayList<>();
                        Lang.getLocaleMap(Locale.ENGLISH).forEach((k, v) -> {
                            if (!Lang.getLocaleMap(selected).containsKey(k)) {
                                list.add(k + "\n");
                            }
                        });
                        StringBuilder sb = new StringBuilder();
                        Collections.sort(list);
                        list.forEach(s -> sb.append(s));
                        JDialog dialog = new JDialog(OpenBSTGUI.this, Lang.get("langcheck"));
                        dialog.getContentPane().setLayout(new MigLayout());
                        dialog.getContentPane().add(new JLabel(Lang.get("langcheck.result")),
                                "pushx, growx, wrap");
                        JTextArea area = new JTextArea();
                        area.setLineWrap(true);
                        area.setWrapStyleWord(true);
                        area.setText(sb.toString());
                        area.setEditable(false);
                        area.setBorder(BorderFactory.createLoweredBevelBorder());
                        JScrollPane jsp = new JScrollPane(area);
                        jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
                        dialog.getContentPane().add(jsp, "pushx, pushy, growx, growy");
                        dialog.setSize((int) (Icons.getScale() * 300), (int) (Icons.getScale() * 300));
                        dialog.setLocationRelativeTo(OpenBSTGUI.this);
                        dialog.setModalityType(ModalityType.APPLICATION_MODAL);
                        dialog.setVisible(true);
                    }
                }
            }));

    additionalMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.debug"), new ImageIcon(Icons.getImage("Code", 16))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    DebugInfo.launch(OpenBSTGUI.this);
                }
            }));

    JMenu includedFiles = new JMenu("Included BST files");

    for (Entry<String, String> entry : OpenBST.getInternalFiles().entrySet()) {
        JMenuItem jmi = new JMenuItem(entry.getKey());
        jmi.addActionListener(ev -> {
            String path = "/bst/" + entry.getValue();
            InputStream is = OpenBSTGUI.class.getResourceAsStream(path);
            ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(OpenBSTGUI.this, "Extracting...",
                    is);
            new Thread(() -> {
                try {
                    File f = File.createTempFile("openbstinternal", ".bsp");
                    FileOutputStream fos = new FileOutputStream(f);
                    IOUtils.copy(pmis, fos);
                    openStory(f);
                } catch (final IOException e) {
                    LOG.error("IOException caught", e);
                    showException(Lang.get("file.error").replace("$e", e.getClass().getSimpleName())
                            .replace("$m", e.getMessage()), e);
                }

            }).start();

        });
        includedFiles.add(jmi);
    }
    additionalMenu.add(includedFiles);

    shortMenu.addSeparator();

    JMenu themesMenu = new JMenu(Lang.get("menu.themes"));
    shortMenu.add(themesMenu);
    themesMenu.setIcon(new ImageIcon(Icons.getImage("Color Wheel", 16)));
    ButtonGroup themesGroup = new ButtonGroup();
    JRadioButtonMenuItem jrbmi;

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.dark"));
    if (0 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(0, DARK_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.light"));
    if (1 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(1, LIGHT_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    jrbmi = new JRadioButtonMenuItem(Lang.get("menu.themes.debug"));
    if (2 == selectedTheme) {
        jrbmi.setSelected(true);
    }
    jrbmi.addActionListener(e -> switchLaF(2, DEBUG_THEME));
    themesMenu.add(jrbmi);
    themesGroup.add(jrbmi);

    JMenu additionalLightThemesMenu = new JMenu(Lang.get("menu.themes.morelight"));
    int j = 3;
    for (Map.Entry<String, LookAndFeel> entry : ADDITIONAL_LIGHT_THEMES.entrySet()) {
        int jf = j;
        jrbmi = new JRadioButtonMenuItem(entry.getKey());
        if (j == selectedTheme)
            jrbmi.setSelected(true);
        jrbmi.addActionListener(e -> switchLaF(jf, entry.getValue()));
        additionalLightThemesMenu.add(jrbmi);
        themesGroup.add(jrbmi);
        j++;
    }
    themesMenu.add(additionalLightThemesMenu);

    JMenu additionalDarkThemesMenu = new JMenu(Lang.get("menu.themes.moredark"));
    for (Map.Entry<String, LookAndFeel> entry : ADDITIONAL_DARK_THEMES.entrySet()) {
        int jf = j;
        jrbmi = new JRadioButtonMenuItem(entry.getKey());
        if (j == selectedTheme)
            jrbmi.setSelected(true);
        jrbmi.addActionListener(e -> switchLaF(jf, entry.getValue()));
        additionalDarkThemesMenu.add(jrbmi);
        themesGroup.add(jrbmi);
        j++;
    }
    themesMenu.add(additionalDarkThemesMenu);

    shortMenu.add(new JMenuItem(
            new AbstractAction(Lang.get("menu.about"), new ImageIcon(Icons.getImage("About", 16))) {
                /**
                 *
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    new AboutDialog(instance).setVisible(true);
                }
            }));

    return shortMenu;
}

From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java

@SuppressWarnings("unchecked")
public AboutDialog(OpenBSTGUI parent) {
    super(parent);
    setTitle(Lang.get("about.title"));
    setModalityType(ModalityType.APPLICATION_MODAL);

    JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER));
    banner.setBackground(OpenBSTGUI.OPENBST_BLUE);
    JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48)));
    lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    banner.add(lblOpenbst, "flowx,cell 0 0,alignx center");
    getContentPane().add(banner, BorderLayout.NORTH);

    JPanel pan = new JPanel();
    pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]"));
    getContentPane().add(pan, BorderLayout.CENTER);

    JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/");
    Font f = lblWebsite.getFont();
    @SuppressWarnings("rawtypes")
    Map attrs = f.getAttributes();
    attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    lblWebsite.setFont(f.deriveFont(attrs));
    lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE);
    lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblWebsite.addMouseListener(new MouseAdapter() {
        @Override//from w w  w .ja v a 2s.  co  m
        public void mouseClicked(MouseEvent e) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI());
                } catch (IOException | URISyntaxException e1) {
                    OpenBST.LOG.warn("Exception when trying to open website", e1);
                }
            }
        }
    });
    pan.add(lblWebsite, "cell 0 0,alignx center");

    JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION));
    pan.add(lblVersion, "flowy,cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false));
    pan.add(scrollPane, "cell 0 2,grow");

    JTextArea textArea = new JTextArea();
    textArea.setMargin(new Insets(5, 5, 5, 5));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11)));

    try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) {
        textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8));
    } catch (IOException ex) {
        OpenBST.LOG.warn("Loading about information failed", ex);
    }
    textArea.setEditable(false);
    textArea.setCaretPosition(0);
    scrollPane.setViewportView(textArea);

    JLabel lblTranslatedBy = new JLabel(Lang.get("author"));
    pan.add(lblTranslatedBy, "cell 0 1");

    setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400));
    setLocationRelativeTo(parent);
}

From source file:Widgets.Simulation.java

public Simulation(final JFrame aFrame, NetworkElement item) {
    super(aFrame);
    grn = ((DynamicalModelElement) item).getGeneNetwork();
    plot = new Plot2DPanel();

    //closing listener
    this.addWindowListener(new WindowAdapter() {
        @Override// w  w  w .j  a  v a  2  s.  c o  m
        public void windowClosing(WindowEvent windowEvent) {
            if (simulation != null && simulation.myThread_.isAlive()) {
                simulation.stop();
                System.out.print("Simulation is canceled.\n");
                JOptionPane.showMessageDialog(new Frame(), "Simulation is canceled.", "Warning!",
                        JOptionPane.INFORMATION_MESSAGE);
            }
            escapeAction();
        }
    });

    // Model
    model_.setModel(new DefaultComboBoxModel(new String[] { "Deterministic Model (ODEs)",
            "Stochastic Model (SDEs)", "Stochastic Simulation (Gillespie Algorithm)" }));
    model_.setSelectedIndex(0);

    setModelAction();

    //set plot part
    //display result
    if (grn.getTimeScale().size() >= 1) {
        //update parameters
        numTimeSeries_.setValue(grn.getTraj_itsValue());
        tmax_.setValue(grn.getTraj_maxTime());
        sdeDiffusionCoeff_.setValue(grn.getTraj_noise());

        if (grn.getTraj_model().equals("ode"))
            model_.setSelectedIndex(0);
        else if (grn.getTraj_model().equals("sde"))
            model_.setSelectedIndex(1);
        else
            model_.setSelectedIndex(2);

        //update plot
        trajPlot.removeAll();
        trajPlot.add(trajectoryTabb());
        trajPlot.updateUI();
        trajPlot.setVisible(true);
        trajPlot.repaint();

        analyzeResult.setVisible(true);
    }

    /**
     * ACTIONS
     */

    model_.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setModelAction();
        }
    });

    analyzeResult.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            final JDialog a = new JDialog();
            a.setSize(new Dimension(500, 450));
            a.setModal(true);
            a.setTitle("Gene List (seperated by ';')");
            a.setLocationRelativeTo(null);

            final JTextArea focusGenesArea = new JTextArea();
            focusGenesArea.setLineWrap(true);
            focusGenesArea.setEditable(false);
            focusGenesArea.setRows(3);

            String geneNames = "";
            for (int i = 0; i < grn.getNodes().size(); i++)
                geneNames += grn.getNodes().get(i).getLabel() + ";";
            focusGenesArea.setText(geneNames);

            JButton submitButton = new JButton("Submit");
            JButton cancelButton = new JButton("Cancel");
            JPanel buttonPanel = new JPanel();
            buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
            buttonPanel.add(submitButton);
            buttonPanel.add(cancelButton);

            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(final ActionEvent arg0) {
                    a.dispose();
                }
            });

            submitButton.addActionListener(new ActionListener() {
                public void actionPerformed(final ActionEvent arg0) {
                    a.dispose();
                    final JDialog a = new JDialog();
                    a.setSize(new Dimension(500, 450));
                    a.setModal(true);
                    a.setTitle("Statistics");
                    a.setLocationRelativeTo(null);

                    if (grn.getTimeSeries().isEmpty()) {
                        JOptionPane.showMessageDialog(new Frame(), "Please run the simulation first.",
                                "Warning!", JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JPanel infoPanel = new JPanel();
                        infoPanel.setLayout(new BorderLayout());

                        //output 
                        String[] focusGenes = focusGenesArea.getText().split(";");
                        ;
                        String content = "";

                        //discrete the final state
                        int dimension = grn.getNodes().size();

                        //get gene index
                        int[] focus_index = new int[focusGenes.length];
                        for (int j = 0; j < focusGenes.length; j++)
                            for (int i = 0; i < dimension; i++)
                                if (grn.getNode(i).getLabel().equals(focusGenes[j]))
                                    focus_index[j] = i;

                        JScrollPane jsp = new JScrollPane();
                        //calculate steady states      
                        grn.setLand_itsValue((Integer) numTimeSeries_.getModel().getValue());
                        int[] isConverge = new int[grn.getTraj_itsValue()];
                        String out = calculateSteadyStates(focusGenes, focus_index, isConverge);

                        //show the convergence
                        final JDialog ifconvergent = new JDialog();
                        ifconvergent.setSize(new Dimension(500, 450));
                        ifconvergent.setModal(true);
                        ifconvergent.setTitle("Convergence");
                        ifconvergent.setLocationRelativeTo(null);

                        ConvergenceTable tablePanel = new ConvergenceTable(isConverge);
                        JButton continueButton = new JButton("Click to check the attractors.");
                        continueButton.addActionListener(new ActionListener() {
                            public void actionPerformed(final ActionEvent arg0) {
                                ifconvergent.dispose();
                            }
                        });

                        JPanel ifconvergentPanel = new JPanel();
                        ifconvergentPanel.setLayout(new BorderLayout());
                        ifconvergentPanel.add(tablePanel, BorderLayout.NORTH);
                        ifconvergentPanel.add(continueButton, BorderLayout.SOUTH);

                        ifconvergent.add(ifconvergentPanel);
                        ifconvergent.setVisible(true);

                        //show attractors
                        if (out.equals("ok")) {
                            AttractorTable panel = new AttractorTable(grn, focusGenes);
                            jsp.setViewportView(panel);
                        } else if (grn.getSumPara().size() == 0)
                            content += "Cannot find a steady state!";
                        else
                            content += "\nI dont know why!";

                        if (content != "") {
                            JLabel warningLabel = new JLabel();
                            warningLabel.setText(content);
                            jsp.setViewportView(warningLabel);
                        }

                        grn.setSumPara(null);
                        grn.setCounts(null);

                        //jsp.setPreferredSize(new Dimension(280,130));
                        jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
                        jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                        infoPanel.add(jsp, BorderLayout.CENTER);

                        a.add(infoPanel);
                        a.setVisible(true);
                    } //end of else
                }

            });

            JPanel options3 = new JPanel();
            options3.setLayout(new BorderLayout());
            options3.add(focusGenesArea, BorderLayout.NORTH);
            options3.add(buttonPanel);

            options3.setBorder(new EmptyBorder(5, 0, 5, 0));

            a.add(options3);
            a.setVisible(true);
        }
    });

    runButton_.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            //System.out.print("Memory start: "+s_runtime.totalMemory()+"\n"); 
            enterAction();
        }
    });

    cancelButton_.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            if (simulation != null)
                simulation.stop();
            System.out.print("Simulation is canceled!\n");
        }
    });

    fixButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            JDialog a = new JDialog();
            a.setTitle("Fixed initial values");
            a.setSize(new Dimension(400, 400));
            a.setLocationRelativeTo(null);

            JPanel speciesPanel = new JPanel();
            String[] columnName = { "Name", "InitialValue" };
            boolean editable = false; //false;
            new SpeciesTable(speciesPanel, columnName, grn, editable);

            /** LAYOUT **/
            JPanel wholePanel = new JPanel();
            wholePanel.setLayout(new BoxLayout(wholePanel, BoxLayout.Y_AXIS));
            wholePanel.add(speciesPanel);

            a.add(wholePanel);
            a.setModal(true);
            a.setVisible(true);
        }
    });

    randomButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent arg0) {
            final JDialog a = new JDialog();
            a.setTitle("Set boundaries");
            a.setSize(new Dimension(300, 200));
            a.setModal(true);
            a.setLocationRelativeTo(null);

            JPanel upPanel = new JPanel();
            JLabel upLabel = new JLabel("Input the upper boundary: ");
            final JTextField upValue = new JTextField("3");
            upPanel.setLayout(new BoxLayout(upPanel, BoxLayout.X_AXIS));
            upPanel.add(upLabel);
            upPanel.add(upValue);

            JPanel lowPanel = new JPanel();
            JLabel lowLabel = new JLabel("Input the lower boundary: ");
            final JTextField lowValue = new JTextField("0");
            lowPanel.setLayout(new BoxLayout(lowPanel, BoxLayout.X_AXIS));
            lowPanel.add(lowLabel);
            lowPanel.add(lowValue);

            JPanel buttonPanel = new JPanel();
            JButton submit = new JButton("Submit");
            JButton cancel = new JButton("Cancel");
            buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
            buttonPanel.add(submit);
            buttonPanel.add(cancel);
            buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

            submit.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if (upValue.getText().equals(""))
                        JOptionPane.showMessageDialog(null, "Please input upper boundary", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    else {
                        try {
                            upbound = Double.parseDouble(upValue.getText());

                            if (lowValue.getText().equals(""))
                                JOptionPane.showMessageDialog(null, "Please input lower boundary", "Error",
                                        JOptionPane.ERROR_MESSAGE);
                            else {
                                try {
                                    lowbound = Double.parseDouble(lowValue.getText());

                                    if (upbound < lowbound)
                                        JOptionPane.showMessageDialog(null,
                                                "Upper boundary should be not less than lower boundary",
                                                "Error", JOptionPane.ERROR_MESSAGE);
                                    else
                                        a.dispose();
                                } catch (Exception er) {
                                    JOptionPane.showMessageDialog(null, "Invalid value", "Error",
                                            JOptionPane.INFORMATION_MESSAGE);
                                    MsgManager.Messages.errorMessage(er, "Error", "");
                                }
                            }
                        } catch (Exception er) {
                            JOptionPane.showMessageDialog(null, "Invalid value", "Error",
                                    JOptionPane.INFORMATION_MESSAGE);
                            MsgManager.Messages.errorMessage(er, "Error", "");
                        }
                    }

                }
            });

            cancel.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JOptionPane.showMessageDialog(null, "The default values are used!", "",
                            JOptionPane.INFORMATION_MESSAGE);
                    a.dispose();
                }
            });

            JPanel wholePanel = new JPanel();
            wholePanel.setLayout(new BoxLayout(wholePanel, BoxLayout.Y_AXIS));
            wholePanel.add(upPanel);
            wholePanel.add(lowPanel);
            wholePanel.add(buttonPanel);
            wholePanel.setBorder(new EmptyBorder(5, 5, 5, 5));

            a.add(wholePanel);
            a.setVisible(true);

        }
    });
}