只是简单的写出一个界面来,没有添加事件响应。
import java.awt.*;
public class Main {
public static void main(String[] args) {
Frame f = new Frame("Password");
f.setLayout(null);
f.setBounds(500, 500, 300, 220);
f.setBackground(Color.WHITE);
Label l1 = new Label("用户登录");
l1.setBounds(40, 40, 60, 30);
f.add(l1);
Label l2 = new Label("姓名:");
l2.setBounds(40, 80, 60, 30);
f.add(l2);
Label l3 = new Label("密码:");
l3.setBounds(40, 120, 60, 30);
f.add(l3);
Button b1 = new Button("确定(Y)");
b1.setBounds(60, 160, 70, 30);
b1.setBackground(Color.LIGHT_GRAY);
f.add(b1);
Button b2 = new Button("取消(N)");
b2.setBounds(140, 160, 70, 30);
b2.setBackground(Color.LIGHT_GRAY);
f.add(b2);
TextField t1 = new TextField();
t1.setBounds(120, 80, 100, 30);
f.add(t1);
TextField t2 = new TextField();
t2.setBounds(120, 120, 100, 30);
f.add(t2);
f.setVisible(true);
}
}