Reputation: 27
The constructor JTable is giving me an error that says:
"The constructor JTable(int[][], String[]) is undefined"
although it has a constructor JTable(Object[][], Object[])
(Calcul.apartements
is of the type int[][]
)
String[] colonnes = {"Appartements", "Prix Milion de Cts", "Tempd duTrajet/C.v (en min)", "Superficie (en m2)", "Etage"};
table = new JTable(Calcul.appartements, colonnes);
Upvotes: 1
Views: 456
Reputation: 8695
You have two choices:
Calcul.appartements
data to be Object[][]
or Integer[][]
(as mentioned by @MadProgrammer in the comments)Implementing the table model might be as simple as:
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() { return colonnes.length; }
public String getColumnName(int col) { return colonnes[col]; }
public int getRowCount() { return Calcul.appartements.length; }
public Object getValueAt(int row, int col) { Calcul.appartements[row][col]; }
};
JTable table = new JTable(dataModel);
Upvotes: 1