package com.itheima;
import javax.swing.*;
public class JFrame05 {
public static void main(String[] args) {
JFrame jf=new JFrame();
jf.setTitle("用户登录");
jf.setSize(400,300);
jf.setDefaultCloseOperation(3);
jf.setLocationRelativeTo(null);
jf.setAlwaysOnTop(true);
jf.setLayout(null); //取消窗体的默认布局
//显示用户名文本
JLabel usernameLabel=new JLabel("用户名");
usernameLabel.setBounds(50,50,50,20);
jf.add(usernameLabel);
//用户名输入框
JTextField usernameField = new JTextField();
usernameField.setBounds(150,50,180,20);
jf.add(usernameField);
//显示密码文本
JLabel passwordLabel=new JLabel("密码");
passwordLabel.setBounds(50,100,50,20);
jf.add(passwordLabel);
//密码输入框
// JTextField passwordField = new JTextField();
// passwordField.setBounds(150,100,180,20);
// jf.add(passwordField);
JPasswordField passwordField = new JPasswordField(); //密码输入框用JPasswordField 加密显示
passwordField.setBounds(150,100,180,20);
jf.add(passwordField);
//登录按钮
JButton LoginButton=new JButton("登录");
LoginButton.setBounds(50,200,280,20);
jf.add(LoginButton);
//添加按钮到窗体中
jf.setVisible(true);
}
}