银行管理系统 Java前端代码,不需要连接数据库
时间: 2023-12-30 21:04:40 浏览: 28
以下是一个简单的银行管理系统的Java前端代码示例,它使用Swing库来创建图形用户界面(GUI)。这个示例程序不需要连接到数据库,只是用来展示如何创建一个简单的GUI应用程序,你可以根据自己的需求进行修改和扩展。
```
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BankManagementSystemGUI extends JFrame implements ActionListener {
private JLabel welcomeLabel;
private JButton loginButton, registerButton, exitButton;
public BankManagementSystemGUI() {
setTitle("Bank Management System");
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout(4, 1));
welcomeLabel = new JLabel("Welcome to Bank Management System", JLabel.CENTER);
contentPane.add(welcomeLabel);
loginButton = new JButton("Login");
loginButton.addActionListener(this);
contentPane.add(loginButton);
registerButton = new JButton("Register");
registerButton.addActionListener(this);
contentPane.add(registerButton);
exitButton = new JButton("Exit");
exitButton.addActionListener(this);
contentPane.add(exitButton);
}
public void actionPerformed(ActionEvent event) {
if (event.getSource() == loginButton) {
// TODO: add login logic
} else if (event.getSource() == registerButton) {
// TODO: add register logic
} else if (event.getSource() == exitButton) {
System.exit(0);
}
}
public static void main(String[] args) {
BankManagementSystemGUI gui = new BankManagementSystemGUI();
gui.setVisible(true);
}
}
```
这个简单的GUI应用程序包括一个欢迎标签、一个登录按钮、一个注册按钮和一个退出按钮。当用户单击登录或注册按钮时,可以添加逻辑来处理用户输入并执行相应的操作。