Question

I have this renderer that changes the value of JTable cell.

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    String label = value.toString();
    if(label.equals("-")
        label = "error";
    setValue(label);

    return this;
}

In the table's data model, data in row 1, column 2 is "-"
In the JTable GUI, data in at row 1, column 2 is "error"

This code prints the value in data model: "-".

System.out.println(table.getValueAt(1, 2).toString());

Is there any simple way to retrieve the value "error"?

Was it helpful?

Solution

I assume your renderer extends JLabel

((JLabel)table.getCellRenderer(row, column)
.getTableCellRendererComponent(pass all the params here)).getText();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top