I have a JTable and I'm using the DefaultTableModel. I have one row, but I'm trying to add many columns using a for loop because the table is created dynamically.
With addColumn, I understand the first argument should be a string for the column name, but how can I pass a double for the data value in the table? I have read the definitions (the use of object or vector) but I'm having no luck with them:
String colName = "ColName";
double value = 1.2;
model.addColumn(colName, new double[]{ value });
addColumn(Object columnName, Object[] columnData) this method only accepting arrays of objects which are extending from java.lang.Object. So if you use new Double[]{ value } instead of new double[]{ value } it will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With