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

📄 infotablemodel.java

📁 学生信息读系统(根据学生的学号从存储系统读取学生信息): 姓名
💻 JAVA
字号:
//GUI part.
//This TableModel describes all information of a student.
//A JTable will show this TableModel.
import javax.swing.table.AbstractTableModel;

public class InfoTableModel extends AbstractTableModel
{
	//If this TableModel can create successfully.
	public boolean canSuccess=false;
	
	//The ID of student whose information will be 
	//showed in this TableModel.
	protected MyStuInfoReader mir=null;
	
	//The calculate method in CourseReCal class.
	private int calMethod=0;
	
	//The upper information.
	public String stuID=null;
	public String stuName=null;
	
	final String[] columnNames={"科目代号","科目名称","科目总成绩"};
	
	private Object[][] infos=new Object[9][columnNames.length];
	
	//The table information.
	//Later fill in array infos.
	private String[] courseIDs=null;
	private String[] courseNames=null;
	private int[] usualScores=null;
	private int[] examScores=null;
	
	public InfoTableModel(String ino,String stuID)
	{
		super();
		try
		{
		    mir=new MyStuInfoReader(ino);
		    mir.readInfos(stuID);
		    this.stuID=mir.getStuID();
		    this.stuName=mir.getStuName();
		    this.courseIDs=mir.getCouIDs();
		    this.courseNames=mir.getCouNames();
		    this.usualScores=mir.getScoreUsual();
		    this.examScores=mir.getScoreExam();
		    this.setCalMethod(CourseReCal.SEVEN_TO_THREE);
		    fill();
		    canSuccess=true;
		}
		catch(Exception e)
		{
			canSuccess=false;
		}
	}
	
	public int getRowCount()
	{
		return 8;
	}
	
	public int getColumnCount()
	{
		return columnNames.length;
	}
	
	public Object getValueAt(int row,int column)
	{
		return infos[row][column];
	}
	
	public void setCalMethod(int calMe)
	{
		if(calMe<0)
		this.calMethod=0;
		else if(0<=calMe&&calMe<3)
		this.calMethod=calMe;
		else
		this.calMethod=2;
	}
	
	//Fill information in array infos.
	protected void fill()
	{
		for(int i=0;i<3;i++)
		{
			infos[0][i]=columnNames[i];
		    for(int j=1;j<9;j++)
		    {
                if(i==0)
		    	infos[j][i]=courseIDs[j-1];
		    	else if(i==1)
		    	infos[j][i]=courseNames[j-1];
		    	else
		    	infos[j][i]=
		    	new Integer(CourseReCal.getCourseRe(examScores[j-1],usualScores[j-1],this.calMethod));
		    }
		}
	}
}

⌨️ 快捷键说明

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