Example usage for javax.swing JTextArea grabFocus

List of usage examples for javax.swing JTextArea grabFocus

Introduction

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

Prototype

public void grabFocus() 

Source Link

Document

Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window.

Usage

From source file:org.jactr.modules.pm.motor.MotorModuleTest.java

protected JFrame openWindow() {
    final JFrame frame = new JFrame("TextInput");

    try {//from   ww w .j a va 2  s  .c  om
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                JTextArea textArea = new JTextArea();
                frame.getContentPane().add(new JScrollPane(textArea));
                frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
                frame.setVisible(true);
                textArea.grabFocus();
            }
        });
    } catch (Exception e) {

    }

    return frame;
}