package com.one.container;
import javax.swing.*;
import java.awt.*;
public class LoginDemo {
public static void main(String[] args) {
JFrame jf=new JFrame("登入");
//必須設定布局方式,要不然就不顯示,這兩句必須有
//從左到右流布局,最裡面的left是對齊方式
jf.setLayout(new FlowLayout(FlowLayout.LEFT));
//設定視窗大小和尺寸
jf.setBounds(460,300,300,200);
JLabel label1=new JLabel("賬号");
JTextField usernameText=new JTextField("",23);
JLabel label2=new JLabel("密碼");
JPasswordField pwdText =new JPasswordField("",23);
//添加接下來的内容
JTextField out=new JTextField("登入狀态",25);
JButton button =new JButton("登入");
//按順序依次把内容添加到容器中,要不然會看不到内容
jf.add(label1);
jf.add(usernameText);
jf.add(label2);
jf.add(pwdText);
jf.add(out);
jf.add(button);
//設定不可調節大小
jf.setResizable(false);
//設定按鈕大小
//設定可見
jf.setVisible(true);
//設定關閉方式
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}