Java Code Examples for javax.swing.JTextArea.setSelectionEnd()

The following are Jave code examples for showing how to use setSelectionEnd() of the javax.swing.JTextArea class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AWGW   File: WorldFrame.java   Source Code and License Vote up 6 votes
public void handle(Throwable e) {
    e.printStackTrace();

    JTextArea area = new JTextArea(10, 40);
    StringWriter writer = new StringWriter();
    e.printStackTrace(new PrintWriter(writer));
    area.setText(writer.toString());
    area.setCaretPosition(0);
    String copyOption = resources.getString("dialog.error.copy");
    JOptionPane pane = new JOptionPane(new JScrollPane(area), JOptionPane.ERROR_MESSAGE,
            JOptionPane.YES_NO_OPTION, null, new String[]{copyOption, resources.getString("cancel")});
    pane.createDialog(WorldFrame.this, e.toString()).setVisible(true);
    if (copyOption.equals(pane.getValue())) {
        area.setSelectionStart(0);
        area.setSelectionEnd(area.getText().length());
        area.copy(); // copy to clipboard
    }
}