GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes JTable- getValueAt() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JTable- getValueAt()" Watch "JTable- getValueAt()" New topic
Author

JTable- getValueAt()

michael bradly
Ranch Hand

Joined: Oct 06, 2000
Posts: 112
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

Joined: Sep 29, 2000
Posts: 8521
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.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
GeeCON Prague 2014
 
subject: JTable- getValueAt()