package com.sjsq.view;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI;
import com.sjsq.controller.StudentController;
import com.sjsq.controller.impl.StudentControllerImpl;
import com.sjsq.dao.StudentDao;
import com.sjsq.model.Student;
@SuppressWarnings("serial")
public class QueryStudentInfo extends JFrame implements ActionListener {
private JScrollPane panel;
private JButton next, previous, first, last, query;
private JButton modifyBtn, deleteBtn, backBtn;
private JLabel studentId;
private JLabel studengName;
private JLabel studentSex;
private JLabel studentProvince;
private JTextField studentIdContent;
private JTextField studengNameContent;
private JTextField studentSexContent;
private JTextField studentProvinceContent;
private JLabel label1, label2; // 1.显示总页数和当前页数 2.每页显示数
private JTable table;
public int currentPage = 1; // 当前页
public int totalPage = 0; // 总页数
public int totalRowCount = 0; // 总行数
public int pageCount; // 每页显示数目
public int column = 0;
public int restCount; // 最后一页数目
public Object[][] resultData; // 结果集二维数组
// 声明下拉菜单数据
String[] array = { "20", "30", "40", "50", "60" };
JComboBox box = new JComboBox(array);// 将数组array放到下拉菜单中
// JTable表信息相关变量
public List<Student> students = Student.students;
public String[] columnNames = { "学号", "姓名", "性别", "学院", "专业", "生日", "省份", "电话", "邮箱" };
public DefaultTableModel model = null;// 默认的表格控制模型
// 窗体及表的建立
public QueryStudentInfo() {
super("学生信息查询统计");
this.setSize(1040, 680);
setLocationRelativeTo(null);// 将容器显示在屏幕中央
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);// 点击右上角的关闭,只关闭本窗口,不影响住窗口
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
// 设置窗口不可以改变
setResizable(false);
JLabel queryData;
Font font = new Font("微软雅黑", Font.CENTER_BASELINE, 10);
studentId = new JLabel("学号");
studentId.setBounds(100, 30, 40, 30);
studentId.setFont(font);
studentIdContent = new JTextField();
studentIdContent.setBounds(145, 30, 100, 30);
studengName = new JLabel("学生姓名");
studengName.setBounds(270, 30, 70, 30);
studengName.setFont(font);
studengNameContent = new JTextField();
studengNameContent.setBounds(341, 30, 100, 30);
// “姓名”,“性别”,“省份”
studentProvince = new JLabel("省份");
studentProvince.setBounds(100, 65, 40, 30);
studentProvince.setFont(font);
studentProvinceContent = new JTextField();
studentProvinceContent.setBounds(145, 65, 100, 30);
studentSex = new JLabel("学生性别");
studentSex.setBounds(270, 65, 70, 30);
studentSex.setFont(font);
studentSexContent = new JTextField();
studentSexContent.setBounds(341, 65, 100, 30);
query = new JButton("查询");
query.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
query.setBounds(600, 30, 95, 30);
// query.setFont(font);
query.setForeground(Color.blue);
// 设置查询图标
//ImageIcon icon1 = new ImageIcon("src/images/query2.png");
//query.setIcon(icon1);
table = new JTable();
box.setBounds(890, 105, 100, 20);
label2 = new JLabel("每页显示条数:");
label2.setBounds(800, 93, 120, 50);
panel = new JScrollPane();// 设置滚动条
panel.setViewportView(table);
panel.setBounds(42, 136, 950, 420);
first = new JButton("第一页");
first.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
first.setBounds(44, 570, 90, 30);
previous = new JButton("上一页");
previous.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
previous.setBounds(164, 570, 90, 30);
next = new JButton("下一页");
next.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
next.setBounds(284, 570, 90, 30);
last = new JButton("最后一页");
last.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
last.setBounds(404, 570, 90, 30);
/*modifyBtn = new JButton("修改");
modifyBtn.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
modifyBtn.setBounds(524, 570, 90, 30);
deleteBtn = new JButton("删除");
deleteBtn.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.red));
deleteBtn.setBounds(644, 570, 90, 30);
backBtn = new JButton("关闭");
backBtn.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.blue));
backBtn.setBounds(764, 570, 90, 30);*/
// 新的位置
modifyBtn = new JButton("修改");
modifyBtn.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
modifyBtn.setBounds(200, 570, 90, 30);
deleteBtn = new JButton("删除");
deleteBtn.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.red));
deleteBtn.setBounds(400, 570, 90, 30);
backBtn = new JButton("关闭");
backBtn.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.blue));
backBtn.setBounds(600, 570, 90, 30);
/* 添加监听 */
previous.addActionListener(this);
next.addActionListener(this);
first.addActionListener(this);
last.addActionListener(this);
query.addActionListener(this);
// 返回
backBtn.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
dispose();// 点击返回按钮,销毁当前窗口
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
});
// 修改
modifyBtn.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
int selectedRowIndex = 7;
selectedRowIndex = table.getSelectedRow();
if (selectedRowIndex == -1) {
JOptionPane.showMessageDialog(null, "请在表格中选中一条数据", "消息提示", JOptionPane.WARNING_MESSAGE);
} else {
String sid = table.getValueAt(selectedRowIndex, 0).toString();
String sname = table.getValueAt(selectedRowIndex, 1).toString();
String ssex = table.getValueAt(selectedRowIndex, 2).toString();
String scollege = table.getValueAt(selectedRowIndex, 3).toString();
String smajor = table.getValueAt(selectedRowIndex, 4).toString();
String sbirthday = table.getValueAt(selectedRowIndex, 5).toString();
String sprovince = table.getValueAt(selectedRowIndex, 6).toString();
String sphone = table.getValueAt(selectedRowIndex, 7).toString();
String semail = table.getValueAt(selectedRowIndex, 8).toString();
EditStudentInfo editStudentInfo = new EditStudentInfo(sid, sname, ssex, scollege, smajor, sbirthday,
sprovince, sphone, semail);
}
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
});
deleteBtn.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println("------用户点击按钮------");
int selectedRowIndex = 7;
selectedRowIndex = table.getSelectedRow();
if (selectedRowIndex == -1) {
JOptionPane.showMessageDialog(null, "请在表格中选中一条数据", "消息提示",
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Java+Swing+Mysql实现学生信息管理系统 (120个子文件)
QueryStudentInfo.class 13KB
AddStudentInfo.class 10KB
EditStudentInfo.class 9KB
StudentDao.class 6KB
LoginFrame.class 6KB
ModifyPasswordInfo.class 4KB
DBUtil.class 4KB
EditStudentInfo$1.class 4KB
MainMenuFrame.class 4KB
UserDao.class 3KB
Student.class 3KB
Prompt.class 3KB
QueryStudentInfo$3.class 2KB
QueryStudentInfo$2.class 2KB
LoginFrame$2.class 2KB
MD5Util.class 2KB
Help.class 1KB
AboutSystem.class 1KB
EditStudentInfo$3.class 1KB
EditStudentInfo$2.class 1KB
QueryStudentInfo$4.class 1KB
QueryStudentInfo$1.class 1KB
LoginFrame$1.class 1KB
MainMenuFrame$3.class 993B
User.class 988B
MainMenuFrame$1.class 987B
MainMenuFrame$2.class 981B
MainMenuFrame$5.class 973B
StudentControllerImpl.class 943B
MainMenuFrame$4.class 902B
ByteUtil.class 848B
ModifyPasswordInfo$1.class 834B
FileUtil.class 752B
MainMenuFrame$6.class 728B
StudentController.class 264B
.classpath 528B
user.gif 4KB
user.gif 4KB
SwingSets3(BeautyEyeLNFDemo).jar 6.2MB
mysql-connector-java-8.0.13.jar 2.03MB
swingx-core-1.6.2-java7-patched.jar 1.38MB
QueryStudentInfo.java 19KB
EditStudentInfo.java 13KB
AddStudentInfo.java 12KB
LoginFrame.java 6KB
StudentDao.java 6KB
MainMenuFrame.java 4KB
ModifyPasswordInfo.java 4KB
DBUtil.java 3KB
Student.java 2KB
UserDao.java 2KB
Prompt.java 2KB
Help.java 2KB
MD5Util.java 1KB
AboutSystem.java 962B
StudentControllerImpl.java 584B
User.java 567B
ByteUtil.java 366B
FileUtil.java 358B
StudentController.java 202B
5.jpg 523KB
5.jpg 523KB
1.jpg 448KB
1.jpg 448KB
3.jpg 427KB
3.jpg 427KB
2.jpg 412KB
2.jpg 412KB
4.jpg 348KB
4.jpg 348KB
jlu.jpg 284KB
jlu.jpg 284KB
logo.jpg 50KB
logo.jpg 50KB
jlu1.jpg 34KB
jlu1.jpg 34KB
i-qrcode.png 22KB
i-qrcode.png 22KB
weibo.png 17KB
weibo.png 17KB
weixin.png 14KB
weixin.png 14KB
shiye.png 5KB
shiye.png 5KB
add.png 1KB
add.png 1KB
help.png 1KB
help.png 1KB
base3.png 974B
base3.png 974B
about.png 931B
about.png 931B
query1.png 851B
query1.png 851B
query2.png 788B
query2.png 788B
query.png 655B
query.png 655B
modifyPassword.png 582B
modifyPassword.png 582B
共 120 条
- 1
- 2
水坚石青
- 粉丝: 2w+
- 资源: 86
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页