0

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"?

4

1 回答 1

2

我假设你的渲染器扩展JLabel

((JLabel)table.getCellRenderer(row, column)
.getTableCellRendererComponent(pass all the params here)).getText();
于 2013-07-24T12:04:44.030 回答