Spurious calls to setValueAt with JTables in Java 7 on OS X Lion?

Viewed 913

After upgrading to Lion, and Java 7, I am running into issues with JTables. When I use arrow keys to move the selection around, its calling setValueAt() with empty strings as the edit value.

To test this, I created a simple JFrame with a table in it, and set the following class as its model.

public class SpyModel extends AbstractTableModel {
    public int getColumnCount() { return 5; }
    public int getRowCount() { return 5; }
    public Object getValueAt(int rowIndex, int columnIndex) { return ""; }
    public boolean isCellEditable(int rowIndex, int columnIndex) { return true; }

    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        System.out.println(aValue == null ? "null" : "\"" + aValue + "\"");
    }
}

When I run it under Java 6, and then use the arrow keys to move through it. it works fine. e.g.

$ java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)
$ java -jar JavaApplication5.jar 

However, when I run it under Java 7 (on Lion), and move the selection with the arrow keys, it ends up calling setValueAt() with empty strings.

e.g.

$ java -version
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
$ java -jar JavaApplication5.jar 
""
""
""
""
""
$

I've searched for bugs, but I haven't come up with anything. Is this a known problem?

3 Answers
Related