求用Java编写的学生成绩管理系统的完整代码package jdbcproj;
import java.sql.*;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
public class MainFrame extends JFrame {
private JPanel contentPane;
private JTextField txtname;
private JTextField txtpassword;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainFrame frame = new MainFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public MainFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 661, 399);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("\u7528\u6237\u540D");
lblNewLabel.setBounds(114, 51, 72, 18);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("\u5BC6\u7801");
lblNewLabel_1.setBounds(114, 106, 72, 18);
contentPane.add(lblNewLabel_1);
txtname = new JTextField();
txtname.setBounds(261, 48, 86, 24);
contentPane.add(txtname);
txtname.setColumns(10);
txtpassword = new JTextField();
txtpassword.setBounds(261, 103, 86, 24);
contentPane.add(txtpassword);
txtpassword.setColumns(10);
JButton btnadd = new JButton("\u589E\u52A0");
btnadd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Users u=new Users();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAO usdo=new UserDAO();
usdo.addUser(u);
}
}
});
btnadd.setBounds(45, 205, 113, 27);
contentPane.add(btnadd);
JButton btndelete = new JButton("\u5220\u9664");
btndelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
UserDAO usdo=new UserDAO();
usdo.delUser(txtname.getText());;
}
}
});
btndelete.setBounds(172, 205, 113, 27);
contentPane.add(btndelete);
JButton btnupdate = new JButton("\u4FEE\u6539");
btnupdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Users u=new Users();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAO usdo=new UserDAO();
usdo.updateUser(u);;
}
}
});
btnupdate.setBounds(300, 205, 113, 27);
contentPane.add(btnupdate);
JButton btnfind = new JButton("\u67E5\u8BE2");
btnfind.addActionListener(new ActionListener() {
推荐阅读
- 直播都有什么程序流量,直播需要的流量
- 鸿蒙系统网速显示在哪里,鸿蒙系统测网速在哪
- 青岛每日优购小程序开发,青岛每日优购小程序开发怎么样
- 坦克类单机游戏苹果的简单介绍
- python正切余切函数 python 余切函数
- php7.1数据库连接,php数据库怎么连接
- 怎么判断显卡偷没偷懒,怎么判断显卡是否有问题
- 如何开展电商招商,电商项目招商
- c语言正数变为负数函数 c++正数变负数