Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Jtable

 
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);
 
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

}
 
What's gotten into you? Could it be this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic