A
A
Anton @ Lyalin2016-10-27 17:32:40
Java
Anton @ Lyalin, 2016-10-27 17:32:40

How to display elements on JTable?

There is a code to display an array in a JTable, but an error occurs.
The JTable is created like this...

public static void setArrayJTable(JTable jTable){
        for (int i = 1; i < jTable.getRowCount(); i++){
            jTable.setValueAt("0 = ", i, 0);
        }
        for (int j = 2; j < jTable.getColumnCount(); j++){
            jTable.setValueAt("-x" + (j - 1), 0, j);
            jTable.setValueAt("1", 0, 1);
        }
    }

What could be the problem?
public static void setArrayJTable(Double[][] arrDouble){
        for (int i = 0; i < Weight; i++){
            for (int j = 0; j < Height; j++){
                arrayJTableClass.jTable.setValueAt(String.valueOf(arrDouble[i][j]), i + 1, j + 1);
            }
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton @ Lyalin, 2016-10-27
@toxa_1995

6cb60233778f430c990d087f19e126e4.png
Here is a screenshot of that one. It should be. When displaying a matrix through this function, described above, the matrix is ​​displayed either incompletely, or it gives an error that the elements were not found, this is if the code is slightly changed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question