This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Jtable" Watch "Jtable" New topic
Author

Jtable

ilwyvd illtvd
Greenhorn

Joined: Oct 20, 2002
Posts: 13
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

Joined: Sep 09, 2002
Posts: 125
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


Regards,<br />Andrea<br /> <br /><a href="http://www.linkedin.com/in/andreagazzarini" target="_blank" rel="nofollow">Andrea Gazzarini</a><br />Skype ID : gazzax72<br />Google Talk ID : a.gazzarini@gmail.com<br /><a href="http://www.andreagazzarini.blogspot.com" target="_blank" rel="nofollow">My Blog</a>
ilwyvd illtvd
Greenhorn

Joined: Oct 20, 2002
Posts: 13
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

}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Jtable
 
Similar Threads
Please Help in sorting JTable on multiple column.
ArrayOutOfBounds exception after removing column from model - not obvious to me why
find integer index in string
ROWID next "big" thing.
CycleChars