日期:2014-05-20 浏览次数:20635 次
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class test1 extends JApplet {
JButton buttonOK;
JTextField name;
JLabel lname,lpsw;
JPasswordField psw;
JTextArea texts;
public void init() {
JPanel panel1 = (JPanel) getContentPane();
panel1.setLayout(new FlowLayout());
buttonOK = new JButton("OK");
/*JTextArea texts=new JTextArea(2,5);
texts.setLineWrap(true);
panel1.add(texts);*/
name=new JTextField("test",7);
psw=new JPasswordField("1234",7);
lname=new JLabel("name:");
lpsw=new JLabel("psw:");
texts=new JTextArea(10,10);
name = new JTextField(20);
panel1.add(lname);
panel1.add(name);
panel1.add(lpsw);
panel1.add(psw);
panel1.add(texts);
panel1.add(buttonOK);
buttonOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
texts.setText("name:"+name.getText()+"\n pws:"+psw.getText());
}
});
}
}