1.登录界面
package kk;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;
public class login extends JFrame {
JPanel contentPane;
JTextField t1;
String power;
private JPasswordField t2;
String zh,mm;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
login frame = new login();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public login() {
setResizable(false);
setTitle("\u5B66\u751F\u6210\u7EE9\u7BA1\u7406\u7CFB\u7EDF");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 338, 283);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel l1 = new JLabel("\u7528\u6237\u540D\uFF1A");
l1.setFont(new Font("宋体", Font.PLAIN, 16));
JLabel l2 = new JLabel("\u5BC6 \u7801\uFF1A");
l2.setFont(new Font("宋体", Font.PLAIN, 16));
t1 = new JTextField();
t1.setColumns(10);
JButton b1 = new JButton("\u767B\u5F55");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if((t1.getText()).equals("1516")&&(t2.getText()).equals("123"))
{
JOptionPane.showMessageDialog(null, "登录成功!用户权限是管理员");
power="管理员";
guanli f = new guanli();
f.setVisible(true);
}
else if((t1.getText()).equals("15")&&(t2.getText()).equals("123456"))
{
JOptionPane.showMessageDialog(null, "登录成功!登录成功!用户权限是游客");
power="游客";
chaxun f = new chaxun();
f.setVisible(true);
}
else JOptionPane.showMessageDialog(null, "登录失败,请重新登录!");
}
});
JButton b3 = new JButton("\u9000\u51FA");
b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
JButton b2 = new JButton("\u91CD\u7F6E");
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
t1.setText("");
t2.setText("");
}
});
t2 = new JPasswordField();
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap(20, Short.MAX_VALUE)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(l1)
.addComponent(l2)
.addComponent(b1))
.addGap(4)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(44)
.addComponent(b2)
.addGap(42)
.addComponent(b3))
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
.addComponent(t2, Alignment.LEADING)
.addComponent(t1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE)))
.addContainerGap(34, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(50)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(l1)
.addComponent(t1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(49)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(l2)
.addComponent(t2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(46)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(b1)
.addComponent(b2)
.addComponent(b3))
.addContainerGap(35, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
this.setLocationRelativeTo(null);
}
}
2.管理界面
package kk;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
public class guanli extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
guanli frame = new guanli();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public guanli() {
setResizable(false);
setTitle("\u7BA1\u7406\u5458\u767B\u5F55");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 463, 322);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JButton b1 = new JButton("\u67E5\u8BE2");
b1.setFont(new Font("宋体", Font.PLAIN, 16));
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
chaxun f = new chaxun();
f.setVisible(true);
}
});
JButton b2 = new JButton("\u589E\u52A0");
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
zengjia f = new zengjia();
f.setVisible(true);
}
});
b2.setFont(new Font("宋体", Font.PLAIN, 16));
JButton b3 = new JButton("\u4FEE\u6539");
b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
xiugai f = new xiugai();
f.setVisible(true);
}
});
b3.setFont(new Font("宋体", Font.PLAIN, 16));
JButton b4 = new JButton("\u5220\u9664");
b4.setFont(new Font("宋体", Font.PLAIN, 16));
b4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
shanchu f = new shanchu();
f.setVisible(true);
}
});
JButton b5 = new JButton("\u5176\u4ED6");
b5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
qita f = new qita();
f.setVisible(true);
}
});
b5.setFont(new Font("宋体", Font.PLAIN, 16));
JButton b6 = new JButton("\u9000\u51FA");
b6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
shutDown();
}
});
b6.setFont(new Font("宋体", Font.PLAIN, 16));
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(b1)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(b2)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(b3)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(b4)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(b5)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(b6)
.addContainerGap(106, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(98)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(b1)
.addComponent(b2)
.addComponent(b3)
.addComponent(b4)
.addComponent(b5)
.addComponent(b6))
.addContainerGap(131, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
this.setLocationRelativeTo(null);
}
private void shutDown(){
this.dispose();
}
}
3.查询界面
package kk;
import java.awt.Color;
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.GridLayout;
import java.awt.Window;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
import java.awt.Dialog.ModalExclusionType;
public class chaxun extends JFrame {
private JPanel contentPane;
private JTextField t1;
private JTextField t2;
String s,t, r1, r2, r3, r4, r5,r6,r7,r8,r9,r10;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
chaxun frame = new chaxun();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public chaxun() {
setResizable(false);
setTitle("\u6210\u7EE9\u67E5\u8BE2");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBord
java课设--简单的学生成绩管理系统(可视化界面,连接MYsql数据库)
最新推荐文章于 2022-02-24 13:43:01 发布
本文介绍了使用Java编程实现一个简单的学生成绩管理系统,该系统具备可视化界面,并能与MySQL数据库进行连接,通过JDBC技术操作SQL进行数据的增删查改。读者将了解到如何设计数据库表结构,创建数据库连接,以及实现界面交互与数据库操作的整合。
摘要由CSDN通过智能技术生成