下面的例子演示了 JTextField 组件具有的其它功能:
//: c14:TextFields.java
// Text fields and Java events.
// <applet code=TextFields width=375 height=125></applet>
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import com.bruceeckel.swing.*;
public class TextFields extends JApplet {
private JButton
b1 = new JButton("Get Text"),
b2 = new JButton("Set Text");
private JTextField
t1 = new JTextField(30),
t2 = new JTextField(30),
t3 = new JTextField(30);
private String s = new String();
private UpperCaseDocument ucd =
//: c14:TextFields.java
// Text fields and Java events.
// <applet code=TextFields width=375 height=125></applet>
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import com.bruceeckel.swing.*;
public class TextFields extends JApplet {
private JButton
b1 = new JButton("Get Text"),
b2 = new JButton("Set Text");
private JTextField
t1 = new JTextField(30),
t2 = new JTextField(30),
t3 = new JTextField(30);
private String s = new String();
private UpperCaseDocument ucd =