package operation;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.SystemColor;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import DAO.Stu_DAO;
import Infomation.All_info;
public class S_InfoFrame extends JFrame{
private static String user; //用于识别是哪个用户登陆
//显示学生信息的标签
private static JLabel s_numInfo;
private static JLabel s_nameInfo;
private static JLabel s_genderInfo;
private static JLabel s_classInfo;
private static JLabel s_brithdayInfo;
private JPanel stuInfo_Pane; //学生信息面板
private static JTable table; //选课列表表格
private JScrollPane courseList_Pane;//选课列表面板
private JScrollPane selectedCourse_Pane; //已选课程面板
private DefaultTableModel tableModel; //表格模型
private Vector<Vector<Object>> rowData; //选课列表行数据
private Vector<String> columNames; //选课列表列名
private static Stu_DAO info_dao;
//已选课程
private JTable selectedTable;
private DefaultTableModel seleTabModel;
private Vector<Vector<Object>> sele_rowData;
private Vector<String> sele_columNames;
private int MAX_COURSE_NUM = 3; //允许选择的最大课程数
public void init() {
setTitle("教务系统");
setSize(629, 512);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Toolkit tk=getToolkit();
Dimension dim=tk.getScreenSize();
int x,y;
x=(int)(dim.getWidth()-500)/2;
y=(int)(dim.getHeight()-500)/2;
setLocation(x, y);
}
public S_InfoFrame(String user) {
super();
this.user = user;
info_dao = new Stu_DAO(this.user);
getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("\u5B66\u751F\u9009\u8BFE\u7CFB\u7EDF");
lblNewLabel.setBounds(172, 10, 256, 76);
lblNewLabel.setFont(new Font("华文彩云", Font.PLAIN, 30));
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
getContentPane().add(lblNewLabel);
JButton personal_info = new JButton("\u4E2A\u4EBA\u4FE1\u606F");
personal_info.setBounds(107, 90, 121, 32);
getContentPane().add(personal_info);
personal_info.addActionListener(new Action());
JButton course_list = new JButton("\u8BFE\u7A0B\u5217\u8868");
course_list.setBounds(238, 90, 121, 32);
getContentPane().add(course_list);
course_list.addActionListener(new Action());
JButton selected_course = new JButton("\u5DF2\u9009\u8BFE\u7A0B");
selected_course.setBounds(369, 90, 121, 32);
getContentPane().add(selected_course);
selected_course.addActionListener(new Action());
stuInfo_Pane = new JPanel();
stuInfo_Pane.setBounds(47, 151, 478, 312);
stuInfo_Pane.setBackground(SystemColor.menu);
stuInfo_Pane.setForeground(Color.BLACK);
stuInfo_Pane.setToolTipText("");
getContentPane().add(stuInfo_Pane);
stuInfo_Pane.setLayout(null);
JLabel s_name = new JLabel("\u5B66\u751F\u59D3\u540D\uFF1A");
s_name.setBounds(21, 57, 85, 26);
s_name.setFont(new Font("宋体", Font.BOLD, 12));
stuInfo_Pane.add(s_name);
JLabel s_gender = new JLabel("\u5B66\u751F\u6027\u522B\uFF1A");
s_gender.setBounds(21, 105, 85, 26);
s_gender.setFont(new Font("宋体", Font.BOLD, 12));
stuInfo_Pane.add(s_gender);
JLabel s_brithday = new JLabel("\u5B66\u751F\u751F\u65E5\uFF1A");
s_brithday.setBounds(21, 151, 85, 26);
s_brithday.setFont(new Font("宋体", Font.BOLD, 12));
stuInfo_Pane.add(s_brithday);
JLabel s_class = new JLabel("\u5B66\u751F\u73ED\u7EA7\uFF1A");
s_class.setBounds(21, 194, 85, 26);
s_class.setFont(new Font("宋体", Font.BOLD, 12));
stuInfo_Pane.add(s_class);
s_numInfo = new JLabel("");
s_numInfo.setBounds(116, 10, 244, 37);
s_numInfo.setHorizontalAlignment(SwingConstants.CENTER);
stuInfo_Pane.add(s_numInfo);
s_nameInfo = new JLabel("");
s_nameInfo.setBounds(116, 58, 235, 37);
s_nameInfo.setHorizontalAlignment(SwingConstants.CENTER);
stuInfo_Pane.add(s_nameInfo);
s_genderInfo = new JLabel("");
s_genderInfo.setBounds(116, 104, 235, 37);
s_genderInfo.setHorizontalAlignment(SwingConstants.CENTER);
stuInfo_Pane.add(s_genderInfo);
s_brithdayInfo = new JLabel("");
s_brithdayInfo.setBounds(116, 140, 235, 37);
s_brithdayInfo.setHorizontalAlignment(SwingConstants.CENTER);
stuInfo_Pane.add(s_brithdayInfo);
s_classInfo = new JLabel("");
s_classInfo.setBounds(116, 194, 235, 37);
s_classInfo.setHorizontalAlignment(SwingConstants.CENTER);
stuInfo_Pane.add(s_classInfo);
JLabel s_num = new JLabel("\u5B66\u751F\u5B66\u53F7\uFF1A");
s_num.setBounds(21, 20, 578, 15);
stuInfo_Pane.add(s_num);
s_num.setFont(new Font("宋体", Font.BOLD, 12));
JButton modify_pwd = new JButton("\u4FEE\u6539\u5BC6\u7801");
modify_pwd.setBounds(210, 256, 93, 34);
modify_pwd.addActionListener(new Action());
stuInfo_Pane.add(modify_pwd);
courseList_Pane = new JScrollPane();
courseList_Pane.setBounds(19, 151, 580, 253);
courseList_Pane.setVisible(false);
getContentPane().add(courseList_Pane);
columNames = new Vector<>();
columNames.add("");
columNames.add("课程编号");
columNames.add("课程名称");
columNames.add("学分");
columNames.add("任课教师");
columNames.add("教师职称");
columNames.add("上课地点");
columNames.add("已选人数");
rowData = info_dao.getCLVector();
tableModel = new DefaultTableModel(rowData, columNames);
table = new JTable(tableModel);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
courseList_Pane.setViewportView(table);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.getColumnModel().getColumn(0).setCellRenderer(new TableCellRenderer(){
/*(non-Javadoc)
* 此方法返回某一单元格的渲染器(即显示数据的组建--或控件)
* 可以为JCheckBox JComboBox JTextArea 等
* @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
*/
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
// 创建用于返回的渲染组件
JCheckBox ck = new JCheckBox();
// 使具有焦点的行对应的复选框选中
ck.setSelected(isSelected);
ck.setSelected(hasFocus);
// table.findComponentAt();
// 使复选框在单元格内居中显示
ck.setHorizontalAlignment((int) 0.5f);
return ck;
}});
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
//已选课程面板
selectedCourse_Pane = new JScrollPane();
selectedCourse_Pane.setBounds(19, 150, 584, 313);
getContentPane().add(selectedCourse_Pane);
selectedTable = new JTable();
//已选课程表格
sele_columNames = new Vector<>();
sele_columNames.add("课程编号");
sele_columNames.add("课程名称");
sele_columNames.add("学分");
sele_columNames.add("任课教师");
sele_columNames.add("教师职称");
sele_columNames.add("上课地点");
sele_columNames.add("课程成绩");
sele_rowData = info_dao.getSCVector();
seleTabModel = new DefaultTableModel(sele_rowData, sele_columNames);
selectedTable.setModel(seleTabModel);
selectedCourse_Pane.add(selectedTable);
selectedCo
教务管理系统
4星 · 超过85%的资源 需积分: 49 103 浏览量
2016-07-01
18:15:07
上传
评论 16
收藏 596KB RAR 举报
此人已下架
- 粉丝: 23
- 资源: 3
最新资源
- 基于Java的实训在线OJ系统安卓端设计源码
- 基于Vue和TypeScript的房地产管理系统前端设计源码
- 基于微信小程序的通用订票系统设计源码
- 基于ThinkPHP的轻量级PHP开发框架设计源码
- 基于CSS的响应式鲜花网站全屏效果设计源码
- 基于JavaScript的访客预约系统设计源码
- 基于Vue和ECharts的工作租房数据可视化系统设计源码
- 1040g0cg310ravpiu6ibg5pg00tsipsln3ju2d0g 2
- 基于Python的SAR图像去噪CNN-NLM设计源码
- redhat6升级到redhat7,过程redhat6.x-> redhat6.10->rehat7.9 主版本最高版本
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈