JTable(Vector rowData,Vector columnNames) package table;public class grade{String name;int china;int math;int all;boolean ok;public grade(String name,int china,int math,int all,boolean ok) {this.name = name;this.china = china;this.math = math;this.al

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 19:26:57
JTable(Vector rowData,Vector columnNames) package table;public class grade{String name;int china;int math;int all;boolean ok;public grade(String name,int china,int math,int all,boolean ok) {this.name = name;this.china = china;this.math = math;this.al
xUmKY+C>M0QKa,T*RX&8d&ܹI+,MiR]lK[leh*gN&ޛL&/~0}y=9'23 h"NP(O#1aٴ5؉*XC)PNdM#$L8J$^İREĪa!FtU| _m#K:A] ѵuZuQe yx@D"@2{B7,GSp CH=ZPVu^xX. w,0{ NBC3PC:SMFY:cHc1lkМ Nӯ GW!f~$\+F%drH &z6HI8tˢ8X|}<:2"*%Ye mdf7oCڑÜFاZ~GSvq-4Xqew #_|8r䐖Ðn,hmxnm"+ɡ޺W0!89 irxy߰c^6]:#9w'tMMYSN4 cTTekiէ ]0(ޟ~myUG/0gp .x!|ILsL5n-,.MݞGË=$l0ODRO?' ҞLN|,ˍp;0äxͳ;n=D`Žf[/| {Tpd$խdqY;0;V?ӼR}~*ϽbU ؟w6*UVg[S47wխ ^[_#ȇUwd"m!vU cŊHK J}fYW85wx JNX+؜9dMyx

JTable(Vector rowData,Vector columnNames) package table;public class grade{String name;int china;int math;int all;boolean ok;public grade(String name,int china,int math,int all,boolean ok) {this.name = name;this.china = china;this.math = math;this.al
JTable(Vector rowData,Vector columnNames)
package table;
public class grade
{
String name;
int china;
int math;
int all;
boolean ok;
public grade(String name,int china,int math,int all,boolean ok)
{
this.name = name;
this.china = china;
this.math = math;
this.all = all;
this.ok = ok;
}
}
package table;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Vector;
import javax.swing.*;
public class table
{
public table()
{
JFrame f=new JFrame();
Vector va=new Vector();
grade gr1=new grade("网鹏",new Integer(82),new Integer(91),new Integer(100),new Boolean(true));
grade gr2=new grade("网",new Integer(82),new Integer(91),new Integer(100),new Boolean(true));
grade gr=new grade("鹏",new Integer(82),new Integer(91),new Integer(100),new Boolean(true));
va.addElement(gr);
va.addElement(gr2);
va.addElement(gr1);
Vector ve=new Vector();
ve.add("姓名");
ve.add("语文");
ve.add("数学");
ve.add("总分");
ve.add("及格");
JTable table=new JTable(va,ve); // 这里报错为什么啊
table.setPreferredScrollableViewportSize(new Dimension(550,30));
JScrollPane scrollPane=new JScrollPane(table);
f.getContentPane().add(scrollPane,BorderLayout.CENTER);
f.setTitle("表格测试窗口");
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[])
{
new table();
}
}

JTable(Vector rowData,Vector columnNames) package table;public class grade{String name;int china;int math;int all;boolean ok;public grade(String name,int china,int math,int all,boolean ok) {this.name = name;this.china = china;this.math = math;this.al
你的Vector va=new Vector()里面的数据类型都是grade的,而grade又不是数组,所以你的va里面都是一个一个的grade对象,JTable不会自动解析你的grade的构造方法,把它变成String数组,所以你要手动提取出gr1,gr2,gr3中你所需要的数据然后加在不同的Vector对象里面,再把这些Vector对象add到一个Vector类型的对象里面,然后再JTable的构造方法里用这个Vector的对象就可以了