Ai
1 Star 0 Fork 0

123/JavaCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ListFrame.java 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
123 提交于 2021-01-29 01:44 +08:00 . 学生列表界面
package student.view;
import java.awt.*;
import javax.swing.*;
import student.dao.StuDao;
import student.model.Student;
import java.util.*;
/**
* 查询列表类
*
*/
public class ListFrame extends JFrame {
JButton buttonreturn = new JButton("返回");
JTable jtable;
JScrollPane jscrollpane = new JScrollPane();
Vector columnNames = null;
Vector rowData = null;
public ListFrame() {
ArrayList<Student> students = new StuDao().listStu();
JPanel jpforbutton = new JPanel();
columnNames = new Vector();
columnNames.add("学号");
columnNames.add("姓名");
columnNames.add("性别");
columnNames.add("出生日期");
columnNames.add("政治面貌");
columnNames.add("家庭住址");
columnNames.add("电话");
columnNames.add("宿舍号");
rowData = new Vector();
jpforbutton.add(buttonreturn);
for (int i = 0; i < students.size(); i++) {
Vector hang = new Vector();
hang.add(students.get(i).getNumber());
hang.add(students.get(i).getName());
hang.add(students.get(i).getSex());
hang.add(students.get(i).getBirthday());
hang.add(students.get(i).getPoliticalStatus());
hang.add(students.get(i).getHomeAddress());
hang.add(students.get(i).getPhone());
hang.add(students.get(i).getDormitoryNum());
rowData.add(hang);
}
jtable = new JTable(rowData, columnNames);
jscrollpane = new JScrollPane(jtable);
this.setLayout(new FlowLayout());
this.add(jscrollpane);
this.add(jpforbutton);
// 窗口标题
this.setTitle("学生系统-学生列表");
// 窗体大小
this.setSize(500, 340);
// 设置图标
this.setIconImage((new ImageIcon("images/logo.jpg")).getImage());
// 设置可关闭进程
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// 获得屏幕宽度
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
// 获得屏幕高度
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
// 居中显示
this.setLocation((width - 500) / 2, (height - 400) / 2);
// 设置窗体可见
this.setVisible(true);
// 可改变窗体大小
this.setResizable(false);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/hao-bingbing/java-code.git
git@gitee.com:hao-bingbing/java-code.git
hao-bingbing
java-code
JavaCode
master

搜索帮助