I can’t get Jtable’s value

Asked

Viewed 22 times

0

So I was trying to look for values in a Jtable, testing if what’s on the x line and the y column matches an object, but it’s not going at all and I don’t know why. I’ve tried everything =(

public Integer[] getRowIndex(Object value, int column) {
    ArrayList<Integer> rows = new ArrayList<>();
    for (int i = model.getRowCount(); i > 0; i--) {
        if (table.getValueAt(i--, column).equals(value)) {
            System.out.println("eai coldizera 2");
            rows.add(i--);
        }
    }
    return rows.toArray(new Integer[rows.size()]);
}

Solved =D

public Integer[] getRowIndex(Object value, int column) {
    ArrayList<Integer> rows = new ArrayList<>();
    for (int i = 0; i < model.getRowCount(); i++) {
        if (table.getValueAt(i, column).equals(value)) {
            rows.add(i);
        }
    }
    return rows.toArray(new Integer[rows.size()]);
}
  • Your question has already been answered in the two that Linkei, one deals calmly in the answers.

  • I was able to solve =D

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.