Link JTextField with System.out in Java
Description
The following code shows how to link JTextField with System.out.
Example
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.text.AbstractDocument;
/*from w w w .j a va 2 s .com*/
public class Main {
public static void main(String[] args) {
JFrame f = new JFrame("Text Field Elements");
JTextField tf = new JTextField(32);
tf.setText("That's one small step for man...");
f.getContentPane().add(tf);
f.pack();
f.setVisible(true);
((AbstractDocument)tf.getDocument()).dump(System.out);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »