double a = Double.parseDouble(txtRangeFrom.getText());
double b = Double.parseDouble(txtRangeTo.getText());
int i = 1;
for (int row = a; row <= b; row++)
for (int col = 1; col <= 1; col++){
tblOut.setValueAt(Double.toString(i),row,col);
i++;
}
}
Thanks any help would be appreciated int a = Integer.parseInt(txtRangeFrom.getText());
Hi i have written this bit of code to allow numbers
to be written to the table. I use "b" as the limit
the numbers go to but when i want to use "a" as the
start point it returns the error loss of precision.
E.g. i enter a = 3 and b = 8 and in the table it
returns 3, 4, 5, 6, 7, 8 in a single column. The
error message reads "Loss of possible precision" and
found : double
required: int
for (int row = a; row <= b; row++)
ror
BUILD FAILED (total time: 0 seconds)
row is an int and you're trying to compare it to b which is a Double.....double a = Double.parseDouble(txtRangeFrom.getText()); double b = Double.parseDouble(txtRangeTo.getText()); int i = 1; for (int row = a; row <= b; row++) for (int col = 1; col <= 1; col++){ tblOut.setValueAt(Double.toString(i),row,col); i++; } } ode] Thanks any help would be appreciated
Because CSAngel said that, that was where the problemCSAngel said the warning was because you were mixing ints and doubles.
was. (above)
int lo = 2;
int hi = 6;
DefaultTableModel model = new DefaultTableModel(hi-lo+1, 1);
for(int value = lo; value <= hi; ++value)
model.setValueAt(String.valueOf(value), value-lo, 0);
table.setModel(model);
DefaultTableModel is in package javax.swing.tablle.