Example usage for javax.swing JTextArea setRows

List of usage examples for javax.swing JTextArea setRows

Introduction

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

Prototype

@BeanProperty(bound = false, description = "the number of rows preferred for display")
public void setRows(int rows) 

Source Link

Document

Sets the number of rows for this TextArea.

Usage

From source file:Main.java

public static void main(String[] args) {
    JPanel topPanel = new JPanel();
    topPanel.setPreferredSize(new Dimension(200, 200));
    topPanel.setBackground(Color.WHITE);

    JTextArea chatArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(chatArea);

    JPanel mainPanel = new JPanel(new BorderLayout(5, 5));
    mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    mainPanel.add(topPanel, BorderLayout.CENTER);
    mainPanel.add(scrollPane, BorderLayout.SOUTH);

    chatArea.getDocument().addDocumentListener(new DocumentListener() {

        @Override//from   w  ww  .  ja  va 2 s  .  co m
        public void insertUpdate(DocumentEvent e) {
            updateLineCount();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateLineCount();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateLineCount();
        }

        private void updateLineCount() {
            int lineCount = chatArea.getLineCount();
            if (lineCount <= 4) {
                chatArea.setRows(lineCount);
                mainPanel.revalidate();
            }
        }
    });

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(mainPanel);
    f.pack();
    f.setVisible(true);
}

From source file:au.org.ala.delta.ui.MessageDialogHelper.java

/**
 * Creates a text area that looks like a JLabel that has a preferredSize calculated to fit
 * all of the supplied text wrapped at the supplied column. 
 * @param text the text to display in the JTextArea.
 * @param numColumns the column number to wrap text at.
 * @return a new JTextArea configured for the supplied text.
 *///from   w w w  . ja v a  2s  .  c o m
private static JTextArea createMessageDisplay(String text, int numColumns) {
    JTextArea textArea = new JTextArea();
    textArea.setEditable(false);

    textArea.setBackground(UIManager.getColor("Label.background"));
    textArea.setFont(UIManager.getFont("Label.font"));

    textArea.setWrapStyleWord(true);
    textArea.setLineWrap(true);
    textArea.setColumns(numColumns);

    String wrapped = WordUtils.wrap(text, numColumns);
    textArea.setRows(wrapped.split("\n").length - 1);

    textArea.setText(text);

    // Need to set a preferred size so that under OpenJDK-6 on Linux the JOptionPanes get reasonable bounds 
    textArea.setPreferredSize(new Dimension(0, 0));

    return textArea;

}

From source file:edu.ku.brc.specify.tasks.subpane.wb.ImportDataFileInfo.java

/**
 *  shows modified (truncated) data after import
 *///from w w w .  jav  a 2s  . c om
protected void showModifiedData() {
    if (importer.getTruncations().size() > 0) {
        JPanel mainPane = new JPanel(new BorderLayout());
        JLabel msg = createLabel(getResourceString("WB_TRUNCATIONS"));
        msg.setFont(msg.getFont().deriveFont(Font.BOLD));
        mainPane.add(msg, BorderLayout.NORTH);

        String[] heads = new String[3];
        String[][] vals = new String[importer.getTruncations().size()][3];
        heads[0] = getResourceString("WB_ROW");
        heads[1] = getResourceString("WB_COLUMN");
        heads[2] = getResourceString("WB_TRUNCATED");

        int row = 0;
        for (DataImportTruncation trunc : importer.getTruncations()) {
            vals[row][0] = String.valueOf(trunc.getRow());
            vals[row][1] = trunc.getColHeader();
            if (vals[row][1].equals("")) {
                vals[row][1] = String.valueOf(trunc.getCol() + 1);
            }
            vals[row++][2] = trunc.getExcluded();
        }

        JTable mods = new JTable(vals, heads);
        mods.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false));

        mainPane.add(UIHelper.createScrollPane(mods), BorderLayout.CENTER);

        CustomFrame cwin = new CustomFrame(getResourceString(MODIFIED_IMPORT_DATA), CustomFrame.OKHELP,
                mainPane);
        cwin.setHelpContext("WorkbenchImportData"); //help context could be more specific
        cwin.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        UIHelper.centerAndShow(cwin);
    }
    if (importer.getMessages().size() > 0) {
        JPanel mainPane = new JPanel(new BorderLayout());
        JTextArea msgs = new JTextArea();
        msgs.setRows(importer.getMessages().size());
        for (String msg : importer.getMessages()) {
            msgs.append(msg);
            msgs.append("\n");
        }
        mainPane.add(msgs, BorderLayout.CENTER);
        CustomFrame cwin = new CustomFrame(getResourceString(MODIFIED_IMPORT_DATA), CustomFrame.OKHELP,
                mainPane);
        cwin.setHelpContext("WorkbenchImportData"); //help context could be more specific
        cwin.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        UIHelper.centerAndShow(cwin);
    }
}

From source file:com.smart.aqimonitor.client.AqiMonitor.java

/**
 * Create the frame.//from   ww w .  java  2  s  .  co m
 */
public AqiMonitor() {
    refSelf = this;
    setPreferredSize(new Dimension(640, 480));
    setTitle("\u7A7A\u6C14\u8D28\u91CF\u76D1\u6D4B");
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(AqiMonitor.class.getResource("/lombok/installer/eclipse/STS.png")));
    setMinimumSize(new Dimension(640, 480));
    setMaximumSize(new Dimension(1024, 768));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 636, 412);
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(640, 480));
    contentPane.setMinimumSize(new Dimension(640, 480));
    contentPane.setMaximumSize(new Dimension(1024, 768));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JPanel mainPanel = new JPanel();
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout(0, 0));

    JPanel contentPanel = new JPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane
            .setViewportBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    contentPanel.add(scrollPane, BorderLayout.CENTER);

    textPane = new AqiTextPane();
    textPane.addInputMethodListener(new InputMethodListener() {

        public void caretPositionChanged(InputMethodEvent event) {

        }

        public void inputMethodTextChanged(InputMethodEvent event) {
            textPane.setCaretPosition(document.getLength() + 1);
        }
    });
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.setForeground(Color.BLACK);
    scrollPane.setViewportView(textPane);
    document = textPane.getStyledDocument();

    document.addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            if (e.getDocument() == document) {
                textPane.setCaretPosition(document.getLength());
            }
        }
    });

    JPanel buttonPanel = new JPanel();
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.setLayout(new BorderLayout(0, 0));

    JLabel lblTipsLabel = new JLabel(
            "Tips\uFF1A\u6587\u4EF6\u4FDD\u5B58\u683C\u5F0Fcsv\u53EF\u7528Excel\u6253\u5F00");
    lblTipsLabel.setForeground(Color.BLUE);
    buttonPanel.add(lblTipsLabel, BorderLayout.WEST);

    JPanel panel = new JPanel();
    buttonPanel.add(panel, BorderLayout.CENTER);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnRetrieve = new JButton("\u624B\u52A8\u83B7\u53D6\u6570\u636E");
    panel.add(btnRetrieve);
    btnRetrieve.setVerticalAlignment(SwingConstants.BOTTOM);

    JButton btnNewButton = new JButton("\u5173\u4E8E");
    btnNewButton.setToolTipText("\u5173\u4E8E");
    btnNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextArea textArea = new JTextArea(
                    "\n        csv\n\n        smartstudio@foxmail.com");
            textArea.setColumns(35);
            textArea.setRows(6);
            textArea.setLineWrap(true);// 
            textArea.setEditable(false);// 
            textArea.setOpaque(false);
            JOptionPane.showMessageDialog(contentPane, textArea, "", JOptionPane.PLAIN_MESSAGE);
        }
    });

    JButton btnSetting = new JButton("\u8BBE\u7F6E");
    btnSetting.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            Point parentPos = refSelf.getLocation();

            AqiSettingDialog settingDialog = new AqiSettingDialog(refSelf, pm25InDetailJob.getAqiParser());
            settingDialog.setModal(true);
            settingDialog.setLocation(parentPos.x + 100, parentPos.y + 150);
            settingDialog.init();
            settingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            settingDialog.setVisible(true);
        }
    });

    JButton btnExportDir = new JButton("\u67E5\u770B\u6570\u636E");
    btnExportDir.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {

                String[] cmd = new String[5];

                String filePath = pm25InDetailJob.getAqiParser().getFilePath();
                File file = new File(filePath);
                if (!file.exists()) {
                    FileUtil.makeDir(file);
                }
                if (!file.isDirectory()) {
                    JOptionPane.showMessageDialog(contentPane, "", "",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                cmd[0] = "cmd";
                cmd[1] = "/c";
                cmd[2] = "start";
                cmd[3] = " ";
                cmd[4] = pm25InDetailJob.getAqiParser().getFilePath();

                Runtime.getRuntime().exec(cmd);

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    panel.add(btnExportDir);
    panel.add(btnSetting);
    panel.add(btnNewButton);
    btnRetrieve.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!isRetrieving) {
                isRetrieving = true;
                Thread firstRun = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        pm25InDetailJob.refresh();
                        isRetrieving = false;
                    }
                });

                firstRun.start();
            }
        }
    });

    init();
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public JTextArea appendTextArea(String label, String tooltip) {
    JTextArea textArea = new JUndoableTextArea();
    textArea.setColumns(defaultTextAreaColumns);
    textArea.setRows(defaultTextAreaRows);
    textArea.setAutoscrolls(true);// w  ww  .j  av a  2  s . co  m
    textArea.add(new JScrollPane());
    setToolTip(textArea, tooltip);
    textArea.getAccessibleContext().setAccessibleDescription(tooltip);
    JTextComponentPopupMenu.add(textArea);
    append(label, new JScrollPane(textArea));
    return textArea;
}

From source file:com.brainflow.application.toplevel.Brainflow.java

private void initExceptionHandler() {
    LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer = new LookAndFeelFactory.UIDefaultsCustomizer() {
        public void customize(UIDefaults defaults) {
            ThemePainter painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
            defaults.put("OptionPaneUI", "com.jidesoft.plaf.basic.BasicJideOptionPaneUI");

            defaults.put("OptionPane.showBanner", Boolean.TRUE); // show banner or not. default is true
            //defaults.put("OptionPane.bannerIcon", JideIconsFactory.getImageIcon(JideIconsFactory.JIDE50));
            defaults.put("OptionPane.bannerFontSize", 13);
            defaults.put("OptionPane.bannerFontStyle", Font.BOLD);
            defaults.put("OptionPane.bannerMaxCharsPerLine", 60);
            defaults.put("OptionPane.bannerForeground",
                    painter != null ? painter.getOptionPaneBannerForeground() : null); // you should adjust this if banner background is not the default gradient paint
            defaults.put("OptionPane.bannerBorder", null); // use default border

            // set both bannerBackgroundDk and // set both bannerBackgroundLt to null if you don't want gradient
            defaults.put("OptionPane.bannerBackgroundDk",
                    painter != null ? painter.getOptionPaneBannerDk() : null);
            defaults.put("OptionPane.bannerBackgroundLt",
                    painter != null ? painter.getOptionPaneBannerLt() : null);
            defaults.put("OptionPane.bannerBackgroundDirection", Boolean.TRUE); // default is true

            // optionally, you can set a Paint object for BannerPanel. If so, the three UIDefaults related to banner background above will be ignored.
            defaults.put("OptionPane.bannerBackgroundPaint", null);

            defaults.put("OptionPane.buttonAreaBorder", BorderFactory.createEmptyBorder(6, 6, 6, 6));
            defaults.put("OptionPane.buttonOrientation", SwingConstants.RIGHT);
        }//from ww  w.ja  v  a2 s.c  om
    };
    uiDefaultsCustomizer.customize(UIManager.getDefaults());

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            e.printStackTrace();
            JideOptionPane optionPane = new JideOptionPane(
                    "Click \"Details\" button to see more information ... ", JOptionPane.ERROR_MESSAGE,
                    JideOptionPane.CLOSE_OPTION);
            optionPane.setTitle("An " + e.getClass().getName() + " occurred in Brainflow : " + e.getMessage());

            JTextArea textArea = new JTextArea();
            StringWriter sw = new StringWriter();
            PrintWriter out = new PrintWriter(sw);
            e.printStackTrace(out);
            // Add string to end of text area
            textArea.append(sw.toString());
            textArea.setRows(10);
            optionPane.setDetails(new JScrollPane(textArea));
            JDialog dialog = optionPane.createDialog(brainFrame, "Warning");
            dialog.setResizable(true);
            dialog.pack();
            dialog.setVisible(true);
        }
    });

}

From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java

/**
* Takes the list of data import errors and displays then to the user
* 
* void/*  w  w  w.java  2s  . co  m*/
*/
protected void showErrors() {
    JList listOfErrors = genListOfErrorWhereTableDataDefiesSizeConstraints(model.getColumnNames(),
            model.getData());

    if ((model.getColumnNames() == null) || (model.getData() == null) || (listOfErrors == null)
            || (listOfErrors.getModel().getSize() == 0)) {
        JTextArea textArea = new JTextArea();
        textArea.setRows(25);
        textArea.setColumns(60);
        //String newline = "\n";
        //for (int i = 0; i < listOfErrors.getModel().getSize(); i++)
        //{
        textArea.append(getResourceString("WB_PARSE_FILE_ERROR2"));
        //}
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setEditable(false);
        textArea.setCaretPosition(0);
        JScrollPane pane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), pane, getResourceString("DATA_IMPORT_ISSUES"),
                JOptionPane.WARNING_MESSAGE);
        okBtn.setEnabled(false);
    } else if (listOfErrors.getModel().getSize() > 0) {
        JTextArea textArea = new JTextArea();
        textArea.setRows(25);
        textArea.setColumns(60);
        String newline = "\n";
        for (int i = 0; i < listOfErrors.getModel().getSize(); i++) {
            textArea.append((String) listOfErrors.getModel().getElementAt(i) + newline + newline);
        }
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setEditable(false);
        textArea.setCaretPosition(0);
        JScrollPane pane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), pane, getResourceString("DATA_IMPORT_ISSUES"),
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:org.springframework.richclient.factory.DefaultComponentFactory.java

public JTextArea createTextArea(int rows, int columns) {
    JTextArea textArea = createTextArea();
    textArea.setRows(rows);
    textArea.setColumns(columns);//w  w w. java  2  s.  co m
    return textArea;
}

From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java

private AbstractWizardPage getAddTagsPage() {
    //setup page/*from  w ww .  j  av a  2s . c o  m*/
    final DefaultWizardPage page = new DefaultWizardPage("Add Tags") {
        @Override
        public void setupWizardButtons() {
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH);
            fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK);
            fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
        }
    };

    page.addText("Variants can be filtered by tag value in the Filter section.");
    page.addText("Add tags for this set of variants:");

    final String[] patternExamples = { "<Tag Name>", "Sequencer", "Sequencer Version", "Variant Caller",
            "Variant Caller Version", "Technician" };

    locationField = new JComboBox(patternExamples);
    locationField.setEditable(true);

    final JPanel tagContainer = new JPanel();
    ViewUtil.applyVerticalBoxLayout(tagContainer);

    final JTextField valueField = new JTextField();

    final String startingValue = "<Value>";
    valueField.setText(startingValue);

    final JTextArea ta = new JTextArea();
    ta.setRows(10);
    ta.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    ta.setEditable(false);

    JLabel button = ViewUtil.createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD));
    button.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {

            if (locationField.getSelectedItem().toString().isEmpty()) {
                DialogUtils.displayError("Tag cannot be empty");
                locationField.requestFocus();
                return;
            } else if (locationField.getSelectedItem().toString().equals(patternExamples[0])) {
                DialogUtils.displayError("Enter a valid tag name");
                locationField.requestFocus();
                return;
            }

            if (valueField.getText().toString().isEmpty()) {
                DialogUtils.displayError("Value cannot be empty");
                valueField.requestFocus();
                return;
            } else if (valueField.getText().equals(startingValue)) {
                DialogUtils.displayError("Enter a valid value");
                valueField.requestFocus();
                return;
            }

            VariantTag tag = new VariantTag((String) locationField.getSelectedItem(), valueField.getText());

            variantTags.add(tag);
            ta.append(tag.toString() + "\n");
            valueField.setText("");
        }
    });

    JPanel container2 = new JPanel();
    ViewUtil.clear(container2);
    ViewUtil.applyHorizontalBoxLayout(container2);
    container2.add(locationField);
    container2.add(ViewUtil.clear(new JLabel(" = ")));
    container2.add(valueField);
    container2.add(button);

    page.addComponent(container2);
    locationField.setToolTipText("Current display range");

    locationField.setPreferredSize(LOCATION_SIZE);
    locationField.setMinimumSize(LOCATION_SIZE);

    valueField.setPreferredSize(LOCATION_SIZE);
    valueField.setMinimumSize(LOCATION_SIZE);

    page.addComponent(tagContainer);

    page.addComponent(new JScrollPane(ta));

    JButton clear = new JButton("Clear");
    clear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            variantTags.clear();
            ta.setText("");
            addDefaultTags(variantTags, ta);
        }
    });

    addDefaultTags(variantTags, ta);

    page.addComponent(ViewUtil.alignRight(clear));

    return page;

}

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 ww .jav a2  s.  c om*/
        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);

        }
    });
}