Example usage for javax.swing JTextArea selectAll

List of usage examples for javax.swing JTextArea selectAll

Introduction

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

Prototype

public void selectAll() 

Source Link

Document

Selects all the text in the TextComponent.

Usage

From source file:org.broad.igv.hic.MainWindow.java

private void getEigenvectorActionPerformed(ActionEvent e) {
    double[] rv;/*  ww  w  .j a va2  s .  co m*/
    try {
        String number = JOptionPane.showInputDialog("Which eigenvector do you want to see?");
        int num = Integer.parseInt(number) - 1;

        rv = hic.getEigenvector(num);

        if (rv != null) {
            String str = "";
            for (int i = 0; i < rv.length; i++) {
                str += rv[i] + "\n";

            }
            JTextArea textArea = new JTextArea(str, 20, 20);
            textArea.setEditable(false);
            textArea.selectAll();
            JScrollPane pane = new JScrollPane(textArea);
            JFrame frame = new JFrame("Principal Eigenvector");
            frame.getContentPane().add(pane);
            frame.pack();
            frame.setVisible(true);

        } else {
            System.err.println("No densities available for this file.");
        }

    } catch (InvalidMatrixException error) {
        JOptionPane.showMessageDialog(this, "Unable to calculate eigenvectors after 30 iterations",
                "Eigenvector error", JOptionPane.ERROR_MESSAGE);
    } catch (NumberFormatException error) {
        JOptionPane.showMessageDialog(this, "You must enter a valid number.\n" + error.getMessage(),
                "Eigenvector error", JOptionPane.ERROR_MESSAGE);
    }

}