⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classintercalate.java

📁 培训时做的学生管理系统.基于J2SE平台开发
💻 JAVA
字号:
package cn.com.dialog.classmanagerdialog.classintercalate;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import cn.com.action.classmanageraction.IntercalateAction;
import cn.com.dao.classmanagerdao.Impl;
import cn.com.vo.classmanagervo.ClassVO;

public class ClassIntercalate {
	public JPanel jpanel;// 课程设置的对话框

	ActionListener action;

	static Impl impl;

	JPanel panel1;// 放置添加、修改、删除、退出按钮

	JPanel panel3;// 放置选课表

	static JTable table;

	static String[] str = { "课程编号", "课程名称", "课时", "课程时段", "学分", "课程状态", "执教老师编号",
			"执教老师姓名", "职务","课程备注"};

	public JPanel buildDialog(String title) {
		if (jpanel == null) {
			jpanel = new JPanel();
			jpanel.setBorder(BorderFactory.createTitledBorder(title));
//			dialog.setName(title);
			jpanel.setLayout(new BorderLayout());
			panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
			panel1.add(buildButton("添加课程"));
			panel1.add(buildButton("修改课程"));
			panel1.add(buildButton("删除课程"));
			jpanel.add(panel1, "North");
			jpanel.add(getJScrollPane(), "Center");
//			jpanel.setModal(true);
//			jpanel.setSize(900, 600);
//			dialog.setSize(900, 600);
//			dialog.setLocationRelativeTo(null);
//			dialog.setVisible(true);
//			dialog.dispose();
		}
		return jpanel;
	}

	public JScrollPane getJScrollPane() {
		JScrollPane scrollpane = new JScrollPane(buildJTable());

		return scrollpane;
	}

	/**
	 * 构造表对象
	 * 
	 * @return
	 */
	public static JTable buildJTable() {
		if (table == null) {
			impl = new Impl();
			Object[][] data = impl.getClassInfo();
			DefaultTableModel model = new DefaultTableModel(data, str);
			table = new JTable(model);
		}
		return table;
	}

	public static ClassVO getInputInfo(ResultSet set) throws SQLException {
		ClassVO vo = null;
		/**
		 * "课程编号", "课程名称", "课时", "课程时段", "学分", "课程状态", "执教老师编号", "执教老师姓名",
		 * "职务"查找
		 * 
		 */
		// 获得新加的课程编号
		while(set.next()){
		int c_id = set.getInt(1);
		String c_name = set.getString(2);
		int c_total = set.getInt(3);
		String c_time = set.getString(4);
		int credithour = set.getInt(5);
		String c_estate = set.getString(6);
		int t_id = set.getInt(7);
		String t_name = set.getString(8);
		String t_duty = set.getString(9);
		String t_remake = set.getString(10);
		 vo = new ClassVO(c_id, c_name, c_total, c_time, credithour, c_estate,
				t_id, t_name, t_duty,t_remake);
		}
		return vo;

	}

	/**
	 * 构建有名字的按钮
	 * 
	 * @param name按钮名字
	 * @return
	 */
	public JButton buildButton(String name) {
		JButton button = new JButton(name);
		action = new IntercalateAction(this);
		button.addActionListener(action);
		return button;
	}

	/**
	 * 创建带图标的按钮
	 * 
	 * @param name
	 * @return
	 */
	private JButton buildButton(String name, String image) {
		JButton button = new JButton(new ImageIcon(image));
		button.setName(name);
		action = new IntercalateAction(this);
		button.addActionListener(action);
		return button;
	}

	public static void main(String[] agrs) {
		ClassIntercalate t = new ClassIntercalate();
		t.buildDialog("添加课程");
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -