出现这种报错信息:Exception in thread "main" java.lang.Error: Unresolved compilation problems:
AbstractTablemodel cannot be resolved
abstracttablemodel cannot be resolved to a type
The method SetReorderingallowed(boolean) is undefined for the type TableColumnModel at reportdatacreat.<init>(reportdatacreat.java:37)
at reportdatacreat.main(reportdatacreat.java:97)
附上代码:import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
//import java.io.file;
import javax.swing.table.*;
import java.util.*;
import javax.swing.border.*;
public class reportdatacreat extends JFrame {
private JLabel label1=new JLabel ("报表格式文件");
private JLabel label2=new JLabel ("文件保存到");
private JButton button1=new JButton ("浏览");
private JButton button2=new JButton ("浏览");
private JButton button3=new JButton ("报表数据生成并显示");
private JButton button4=new JButton ("报表数据生成并保存");
private JTextField text1=new JTextField (10);
private JTextField text2=new JTextField (10);
private Vector vect;//声明一个向量对象
private JTable table=new JTable();
private String title[]={"条件提示","条件值"};
//abstracttablemodel tm ;//定义一个数据表模型变量
private JPanel jpanel1=new JPanel ();
private JPanel jpanel2=new JPanel ();
private JPanel jpanel3=new JPanel ();
private JPanel jpanel3_1=new JPanel ();
private JPanel jpanel3_2=new JPanel ();
public reportdatacreat(){
/******************************************
表模型的定义
******************************************/
vect=new Vector();//实例化向量
AbstractTablemodel =new abstracttablemodel(){
public int getcolumncount(){
return title.length;}//取得表格列数
public int getrowcount(){
return vect.size();}//取得表格行数
public object getvalueat(int row,int column){
if(!vect.isempty())
return
((vector)vect.elementat(row)).elementat(column);
else
return null;}//取得单元格中的属性值
public string getcolumnname(int column){
return title[column];}//设置表格列名
public void setvalueat(object value,int row,int column){}
//数据模型不可编辑,该方法设置为空
public Class getcolumnclass(int c){
return getvalueat(0,c).getclass();
}//取得列所属对象类 SetAutoresizemode
};
JTable tm = new JTable();//生成自己的数据模型
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);//生成水平滚动条
jpanel1.setLayout(new FlowLayout());
jpanel1.add(label1);
jpanel1.add(text1);
jpanel1.add(button1);
TitledBorder titledborder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),"数据生成条件录入");
jpanel2.setLayout(new FlowLayout());
jpanel2.setBorder(titledborder1);
JScrollPane sp=new JScrollPane();
sp.getViewport().add(table,null);
jpanel2.add(sp);
table.getColumnModel().getColumn(0).setPreferredWidth(200);
table.getColumnModel().getColumn(1).setPreferredWidth(200);
table.getColumnModel().SetReorderingallowed(false);
jpanel3_1.setLayout(new FlowLayout());
jpanel3_1.add(label2);
jpanel3_1.add(text2);
jpanel3_1.add(button2);
jpanel3_2.setLayout(new FlowLayout());
jpanel3_2.add(button3);
jpanel3_2.add(button4);
jpanel3.setLayout(new GridLayout(2,1));
jpanel3.add(jpanel3_1);
jpanel3.add(jpanel3_2);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(jpanel1,"north");
this.getContentPane().add(jpanel2,"center");
this.getContentPane().add(jpanel3,"south");
//this.setresizable(false);
this.setSize(500,300);
this.setLocation(120,10);
this.show();
}
public static void main(String args[]){
reportdatacreat msb =new reportdatacreat();
}
}
AbstractTablemodel cannot be resolved
abstracttablemodel cannot be resolved to a type
The method SetReorderingallowed(boolean) is undefined for the type TableColumnModel at reportdatacreat.<init>(reportdatacreat.java:37)
at reportdatacreat.main(reportdatacreat.java:97)
附上代码:import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
//import java.io.file;
import javax.swing.table.*;
import java.util.*;
import javax.swing.border.*;
public class reportdatacreat extends JFrame {
private JLabel label1=new JLabel ("报表格式文件");
private JLabel label2=new JLabel ("文件保存到");
private JButton button1=new JButton ("浏览");
private JButton button2=new JButton ("浏览");
private JButton button3=new JButton ("报表数据生成并显示");
private JButton button4=new JButton ("报表数据生成并保存");
private JTextField text1=new JTextField (10);
private JTextField text2=new JTextField (10);
private Vector vect;//声明一个向量对象
private JTable table=new JTable();
private String title[]={"条件提示","条件值"};
//abstracttablemodel tm ;//定义一个数据表模型变量
private JPanel jpanel1=new JPanel ();
private JPanel jpanel2=new JPanel ();
private JPanel jpanel3=new JPanel ();
private JPanel jpanel3_1=new JPanel ();
private JPanel jpanel3_2=new JPanel ();
public reportdatacreat(){
/******************************************
表模型的定义
******************************************/
vect=new Vector();//实例化向量
AbstractTablemodel =new abstracttablemodel(){
public int getcolumncount(){
return title.length;}//取得表格列数
public int getrowcount(){
return vect.size();}//取得表格行数
public object getvalueat(int row,int column){
if(!vect.isempty())
return
((vector)vect.elementat(row)).elementat(column);
else
return null;}//取得单元格中的属性值
public string getcolumnname(int column){
return title[column];}//设置表格列名
public void setvalueat(object value,int row,int column){}
//数据模型不可编辑,该方法设置为空
public Class getcolumnclass(int c){
return getvalueat(0,c).getclass();
}//取得列所属对象类 SetAutoresizemode
};
JTable tm = new JTable();//生成自己的数据模型
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);//生成水平滚动条
jpanel1.setLayout(new FlowLayout());
jpanel1.add(label1);
jpanel1.add(text1);
jpanel1.add(button1);
TitledBorder titledborder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),"数据生成条件录入");
jpanel2.setLayout(new FlowLayout());
jpanel2.setBorder(titledborder1);
JScrollPane sp=new JScrollPane();
sp.getViewport().add(table,null);
jpanel2.add(sp);
table.getColumnModel().getColumn(0).setPreferredWidth(200);
table.getColumnModel().getColumn(1).setPreferredWidth(200);
table.getColumnModel().SetReorderingallowed(false);
jpanel3_1.setLayout(new FlowLayout());
jpanel3_1.add(label2);
jpanel3_1.add(text2);
jpanel3_1.add(button2);
jpanel3_2.setLayout(new FlowLayout());
jpanel3_2.add(button3);
jpanel3_2.add(button4);
jpanel3.setLayout(new GridLayout(2,1));
jpanel3.add(jpanel3_1);
jpanel3.add(jpanel3_2);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(jpanel1,"north");
this.getContentPane().add(jpanel2,"center");
this.getContentPane().add(jpanel3,"south");
//this.setresizable(false);
this.setSize(500,300);
this.setLocation(120,10);
this.show();
}
public static void main(String args[]){
reportdatacreat msb =new reportdatacreat();
}
}
楼主【ppllxx123123ppllxx】截止到2008-08-01 17:10:11的历史汇总数据(不包括此帖):
发帖的总数量:16 发帖的总分数:323 每贴平均分数:20
回帖的总数量:20 得分贴总数量:2 回帖的得分率:10%
结贴的总数量:12 结贴的总分数:253
无满意结贴数:2 无满意结贴分:30
未结的帖子数:4 未结的总分数:70
结贴的百分比:75.00 % 结分的百分比:78.33 %
无满意结贴率:16.67 % 无满意结分率:11.86 %
楼主加油
取消马甲机器人,请点这里:http://www.java2000.net/mycsdn/robotStop.jsp?usern=ppllxx123123ppllxx
AbstractTablemodel =new abstracttablemodel没有变量的名字,后面的类名也不对
后面代码中好多类的名字都是错的,比如大写写成小写。还有些不正确的强制类型装换。
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
//import java.io.file;
import javax.swing.table.*;
import java.util.*;
import javax.swing.border.*;
public class reportdatacreat extends JFrame {
private JLabel label1=new JLabel ("报表格式文件");
private JLabel label2=new JLabel ("文件保存到");
private JButton button1=new JButton ("浏览");
private JButton button2=new JButton ("浏览");
private JButton button3=new JButton ("报表数据生成并显示");
private JButton button4=new JButton ("报表数据生成并保存");
private JTextField text1=new JTextField (10);
private JTextField text2=new JTextField (10);
private Vector vect;//声明一个向量对象
private JTable table=new JTable();
private String title[]={"条件提示","条件值"};
//abstracttablemodel tm ;//定义一个数据表模型变量
private JPanel jpanel1=new JPanel ();
private JPanel jpanel2=new JPanel ();
private JPanel jpanel3=new JPanel ();
private JPanel jpanel3_1=new JPanel ();
private JPanel jpanel3_2=new JPanel ();
public reportdatacreat(){
/******************************************
表模型的定义
******************************************/
vect=new Vector();//实例化向量
AbstractTablemodel =new abstracttablemodel(){
public int getcolumncount(){
return title.length;}//取得表格列数
public int getrowcount(){
return vect.size();}//取得表格行数
public object getvalueat(int row,int column){
if(!vect.isempty())
return
((vector)vect.elementat(row)).elementat(column);
else
return null;}//取得单元格中的属性值
public string getcolumnname(int column){
return title[column];}//设置表格列名
public void setvalueat(object value,int row,int column){}
//数据模型不可编辑,该方法设置为空
public Class getcolumnclass(int c){
return getvalueat(0,c).getclass();
}//取得列所属对象类 SetAutoresizemode
};
JTable tm = new JTable();//生成自己的数据模型
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF);//生成水平滚动条
jpanel1.setLayout(new FlowLayout());
jpanel1.add(label1);
jpanel1.add(text1);
jpanel1.add(button1);
TitledBorder titledborder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),"数据生成条件录入");
jpanel2.setLayout(new FlowLayout());
jpanel2.setBorder(titledborder1);
JScrollPane sp=new JScrollPane();
sp.getViewport().add(table,null);
jpanel2.add(sp);
table.getColumnModel().getColumn(0).setPreferredWidth(200);
table.getColumnModel().getColumn(1).setPreferredWidth(200);
table.getColumnModel().SetReorderingallowed(false);
jpanel3_1.setLayout(new FlowLayout());
jpanel3_1.add(label2);
jpanel3_1.add(text2);
jpanel3_1.add(button2);
jpanel3_2.setLayout(new FlowLayout());
jpanel3_2.add(button3);
jpanel3_2.add(button4);
jpanel3.setLayout(new GridLayout(2,1));
jpanel3.add(jpanel3_1);
jpanel3.add(jpanel3_2);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(jpanel1,"north");
this.getContentPane().add(jpanel2,"center");
this.getContentPane().add(jpanel3,"south");
//this.setresizable(false);
this.setSize(500,300);
this.setLocation(120,10);
this.show();
}
public static void main(String args[]){
reportdatacreat msb =new reportdatacreat();
}
}
就是楼上说的那个问题 但不知道怎么修改帮帮忙啊
object
isempty
((vector)vect.elementat(row)).elementat(column);
起码这几句一看就是错误的,先把这基本的错误改掉再看别的。
类名首字母大小
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
AbstractTablemodel cannot be resolved
abstracttablemodel cannot be resolved to a type
The method SetReorderingallowed(boolean) is undefined for the type TableColumnModel at reportdatacreat.<init>(reportdatacreat.java:37)
at reportdatacreat.main(reportdatacreat.java:97)