1. 程式人生 > >用JAVA編寫一個簡單密碼框

用JAVA編寫一個簡單密碼框

只是簡單的寫出一個介面來,沒有新增事件響應。

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);
	}
}