• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jtable

 
ilwyvd illtvd
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I HAVE TWO CLASS ONE CREATING TABLE, ANOTHER IS A
TABLE MODEL,I pass through a Object[][] to tablemodel FROM TABLE CLASS,the table
show correctly,and if I GET ANYTHING FROM Object[][] in creating table class,it throw many exception,
the sentence is:
//send Object[] searchSet to model,ok
model1.setset(searchSet);

/** get selected row number from listener
* methods in table created class
*/
Index=dispTable.getSelectedRow();
availableSeats=(String)dispTable.getValueAt
(orderIndex,8);
seatnumber=(Integer.valueOf
(availableSeats)).intValue();
/**error occurs when I get data from object[]
*on the condition Object is not null
*/
System.out.println((String)Object[Index][0][0]);
System.out.println(Object[0].length);
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I HAVE TWO CLASS ONE CREATING TABLE, ANOTHER IS A
TABLE MODEL,I pass through a Object[][] to tablemodel FROM TABLE CLASS,the table
show correctly,and if I GET ANYTHING FROM Object[][] in creating table class,it throw many exception,
the sentence is:
//send Object[] searchSet to model,ok
model1.setset(searchSet);
/** get selected row number from listener
* methods in table created class
*/
Index=dispTable.getSelectedRow();
availableSeats=(String)dispTable.getValueAt
(orderIndex,8);
seatnumber=(Integer.valueOf
(availableSeats)).intValue();
/**error occurs when I get data from object[]
*on the condition Object is not null
*/
System.out.println((String)Object[Index][0][0]);
System.out.println(Object[0].length);
I can't undestand very well your answer...
1) What kind of exception the app raises??
2) Did you assign the model to the table (yourTable.setModel(model1))??
3) Why don't you use standard naming convention for identifier names??
4) Why don't you create a Flight object and let the table model manage a collection of Flights instead of managing untypized data (Object [][])??
Greetings
 
ilwyvd illtvd
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you I did not make the question very clearly,I have resolved the problem,it caused by
my deleterows method in model class, I changed my method programming way as:
/** if the search result is null ,delete all
* rows shown in table,else send the dataobject
* to model
*
*/
if(searchSet!=null)
{

searchSet=newAccess.searchCritial
(startValue,desValue,carrierValue)model1.setset(searchSet,fieldInfo);
}
else
{
for(; model1.getRowCount()>0; model1.removeR(0));}
in table model I use the method() as:
/**It is remove row you selected
public void removeRow(int row)
{
data.remove(row);
fireTableRowsDeleted(row,row);
}

it is runs ok

}
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic