Home>

In short, the essence is this. I read the numbers from the file into a two-dimensional array, now I need to output this array to a tableJTable... As I understand it, you first need to create a model and then add it to the table, for this you need to write something like:

DefaultTableModel model= new DefaultTableModel (matrix1, name);
table1= new JTable (model);

But he writes that there is no such solution. As I understand it, arrays must be of types:object [] []andobject []... Please tell me how to convert arrays to such types. And is this the problem? Now I have arrays of the following types:int [] []andString []...

  • Answer # 1

    Thanks everyone. But I have already found a solution.

    table1.setModel (new AbstractTableModel () {
                            @Override
                            public int getRowCount () {
                                return 5;
                            }
                            @Override
                            public int getColumnCount () {
                                return 5;
                            }
                            @Override
                            public Object getValueAt (int rowIndex, int columnIndex) {
                                return matrix1 [rowIndex] [columnIndex];
                            }
                        });