This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Jtable

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

}
 
You showed up just in time for the waffles! And 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
reply
    Bookmark Topic Watch Topic
  • New Topic