I am trying to input an array of number into a JTable but having problems. Namely the error 'java.lang.double[][] cannot be converted to javax.swing.TableModel ' I am assuming the issue is to do with a JTable not being able to read a double but some clarification or a fix would very helpful thanks.
// Data to be displayed in the JTable,
double[][] mile = {
{1},
{2},
{3 },
{4 },
{5 },
{6 },
{7 },
{8 },
{9 },
{10 },
{11 },
{12 },
{13 },
{14 },
{15 },
{16 },
{17 },
{18 },
{19 },
{20 },
};
double[][] kilo = {
{ 1.609 },
{ 3.218 },
{ 4.827 },
{ 6.436 },
{ 8.045 },
{ 9.654 },
{ 11.263 },
{ 12.872 },
{ 14.481 },
{ 16.09 },
{ 17.699 },
{ 19.308 },
{ 20.917 },
{ 22.526 },
{ 24.135 },
{ 25.825 },
{ 27.434 },
{ 29.043 },
{ 30.654 },
{ 32.261 },
};
// Column Names for the table.
String[] titles = { "Miles", "Kilometers" };
// Create the table which is going to display the information.
JTable table = new JTable(mile, kilo, titles);
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBounds(20,20,650,250);
table.setFillsViewportHeight(true);
infoPanel.add(scrollPane);