如果有需要带数据库的,请小伙伴移步至:java+mysql学生管理系统(附源码,无套路)
事先声明: 程序简易,只是为了记录学习过程,大佬们勿喷,要实在忍不住,麻烦各位大佬轻点喷就是!
但是如果有任何问题,欢迎大家评论,望共同进步!
密码在提示里
这是第一段代码
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Array;
import java.util.ArrayList;
public class Gradation {
public static void main(String[] args) {
JFrame jf = new JFrame("登录");
jf.setBounds(300,200,300,150);
jf.setLocationRelativeTo(null);
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
//绝对布局
JPanel panel = new JPanel(null);
JLabel jl = new JLabel("账户");
jl.setBounds(10,10,200,18);
final JTextField name = new JTextField();
name.setBounds(80,10,150,18);
JLabel jl2 = new JLabel("密码");
jl2.setBounds(10,50,200,18);
final JPasswordField password = new JPasswordField();
password.setBounds(80,50,150,18);
panel.add(jl);
panel.add(name);
panel.add(jl2);
panel.add(password);
//创建一个按钮,点击后获取密码框中输入的密码
JButton jb = new JButton("登录");
jb.setBounds(80,80,60,18);
jb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(name.getText().trim().length() == 0||
new String (password.getPassword()).trim().length() == 0)
{
JOptionPane.showMessageDialog(null,"信息错误");
}
else if(name.getText().trim().equals("66")&a