• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable- getValueAt()

 
michael bradly
Ranch Hand
Posts: 112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on JTables and am trying to create a table that has 12 dates and under each date a random number between 0.0 and 100.0.
I am wondering where calculating the 12 random numbers is best suited? This is what I have so far:
final String[] arrayColumnNames = {dates 1-12}
double[] arrayNumbers = new double[12]
{
for (int i = 0; i < 12; i++)
{ arrayNumbers[i] = 100*Math.random() +1;}
}
... then to retrieve those numbers I have this for getValueAt()
public Object getValueAt(int row, int col)
{ return arrayNumbers.lenght[row][col]
}
Am I on the right track?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you are going to have a method to find the contents of the array, instead of just inlining it to the table, at least have the method return a double, which is what you loaded the array with. Right now you return an Object which you would then needlessly have to cast back into a double.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic