这是部分用chatgpt写的源码,有需要的可以联系
里面的图片可以敲掉
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
public class Login extends JFrame implements ActionListener { private JLabel welcome = new JLabel("假面超级记账系统");
private JLabel userLabel, passwordLabel, imageLabel;
private JTextField usernameField; private JPasswordField passwordField;
private JButton loginButton, registerButton; private CardLayout cardLayout = new CardLayout();
private JPanel cardPanel, imagePanel;
private Users users;
public Login() {
this.init();
}
private void init() {
welcome.setFont(new Font("宋体", Font.PLAIN, 45));
setTitle("假面记账管理系统");
setLayout(new BorderLayout());
userLabel = new JLabel("用户名");
passwordLabel = new JLabel("密码");
registerButton = new JButton("注册");
cardPanel = new JPanel(cardLayout);
imagePanel = new JPanel();
ImageIcon imageIcon = new ImageIcon("D:\\Genshin Impact\\Genshin Impact Game\\ScreenShot\\2022121142631.png"); // 添加图片
Image image = imageIcon.getImage().getScaledInstance(500, 400, java.awt.Image.SCALE_SMOOTH);
imageIcon = new ImageIcon(image);
imageLabel = new JLabel(imageIcon);
JPanel panel1 = new JPanel(new BorderLayout());
usernameField = new JTextField();
passwordField = new JPasswordField();
loginButton = new JButton("登录");
loginButton.addActionListener(this);
JPanel titlepanel = new JPanel(new FlowLayout());//标题面板
JPanel loginpanel = new JPanel();//登录面板
loginpanel.setLayout(null);
welcome.setBounds(250, 100, 400, 40);
userLabel.setBounds(340, 170, 50, 20);
passwordLabel.setBounds(340, 210, 50, 20);
usernameField.setBounds(390, 170, 120, 20);
passwordField.setBounds(390, 210, 120, 20);
loginButton.setBounds(340, 250, 80, 25);
registerButton.setBounds(430, 250, 80, 25);
imageLabel.setBounds(100, 130, 200, 200);
loginpanel.add(welcome);
loginpanel.add(userLabel);
loginpanel.add(passwordLabel);
loginpanel.add(usernameField);
loginpanel.add(passwordField);
loginpanel.add(loginButton);
loginpanel.add(registerButton);
imagePanel.add(imageLabel);
panel1.add(titlepanel, BorderLayout.NORTH);
panel1.add(loginpanel, BorderLayout.CENTER);
panel1.add(imagePanel, BorderLayout.WEST);
cardPanel.add(panel1, "登录");
add(cardPanel);
setBounds(100, 100, 700, 500);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
registerButton.addActionListener(new ActionListener() { //为注册按钮添加监听事件
public void actionPerformed(ActionEvent arg0) {
}
});
}
人工写的,如有相同,联系删除