import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Demo1 {
public static <TextFielt> void main(String[] args) {
JFrame d = new JFrame("我的窗体");
d.setSize(350,280);
d.setLocation(425,200);
final JTextField t = new JTextField(25);
d.add(t);
JButton b = new JButton("转到");
d.add(b);
d.setLayout(new FlowLayout());
final JTextArea ja = new JTextArea(8,25);
d.add(ja);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String s = t.getText();
ja.append (s);
}
});
d.setVisible(true);
}
}
为什么要加final啊? |
|