您的位置:程序门 -> java -> gui 设计



显示一行空白表格,获取用户输入内容


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


显示一行空白表格,获取用户输入内容
发表于:2008-01-16 18:54:22 楼主
class   machinetablemodel   extends   abstracttablemodel{
/**
  *  
  */
private   static   final   long   serialversionuid   =   1l;
java.util.arraylist <machine>   mlist=new   arraylist <machine> (6);
object[]       column=       new       string[]{"机器型号","机身号码","购买途径","购买时间","安装人员","安装时间"};  
public   machinetablemodel(){
addtablemodellistener(new   machinetablemodellistener());
}
public   int   getrowcount(){
return       mlist.size();  
}

public   int   getcolumncount(){
return   column.length;
}

public   string   getcolumnname(int   i){
return   column[i].tostring();
}

public   object   getvalueat(int   row,   int   col)   {
machine   m=mlist.get(row);
        if(col==   0){
        return   m.getindex();
        }else   if(col==   1){
        return   m.getname();
        }else   if(col==   2){
        return   m.getbuy_from();
        }else   if(col==   3){
        return   m.getbuy_date();
        }else   if(col==   4){
        return   m.getinstall();
        }else{
        return   m.getin_date();
        }
}

public   void   setvalueat(object   object,   int   row,   int   col){
machine   m=mlist.get(row);
        if(col==   0){
  m.setindex(object.tostring());
        }else   if(col==   1){
        m.setname(object.tostring());
        }else   if(col==   2){
        m.setbuy_from(object.tostring());
        }else   if(col==   3){
        m.setbuy_date(object.tostring());
        }else   if(col==   4){
        m.setinstall(object.tostring());
        }else{
        m.setin_date(object.tostring());
        }
firetabledatachanged();
}

public   boolean   iscelleditable(int   i,   int   j){
return   true;
}

class   machinetablemodellistener   implements   tablemodellistener{
public   void   tablechanged(tablemodelevent   e)   {
for(machine   m:   mlist){  
for(int   i=   0;   i <   column.length;   i++){  
if(i==   0){
system.out.print(m.getindex()+"\t");
}else   if(i==   1){
system.out.print(m.getname()+"\t");
}else   if(i==   2){
system.out.print(m.getbuy_from()+"\t");
}else   if(i==   3){
system.out.print(m.getbuy_date()+"\t");
}else   if(i==   4){
system.out.print(m.getinstall()+"\t");
}else   if(i==   5){
system.out.print(m.getin_date()+"\t");
}else{

}
}
}
}
}
}
这个表格模型应该怎么样改写才可以?
发表于:2008-01-16 19:00:311楼 得分:0
现在就是没有显示空白行,用户操作也不能输入
欲达到的效果是
输入一行完整数据后,就会生成machine对象
machine类源码如下:  
public       class       machine       {  
private       string       index;  
private       string       name,       sn;  
private       string       buy_from,       buy_date;  
private       string       install,       in_date;  
public       machine(){  

}  

public       machine(string       name){  
this.name=       name;  
}  

public       machine(string       name,       string       sn){  
this.name=       name;  
this.sn=       sn;  
}  
....


快速检索

最新资讯
热门点击