如何识别一行是否失去了 vaadin 表的焦点

How to recognize if a row lost focus with vaadin tables

有没有办法识别选定的行是否失去焦点(用户选择另一行或单击其他地方)?我猜 addItemClickListener 不会在这里工作。

示例:
我有一个 table 按钮,只有在选择该行时才会启用这些按钮。

您可以在 table 上使用 valueChangeListener。 在单select 模式下,您会收到 selected 物品,在多select 模式下,您会收到包含所有 selected 物品的套装。

// Allow selecting items from the table.
table.setSelectable(true);

// Send changes in selection immediately to server.
table.setImmediate(true);

// Shows feedback from selection.
final Label current = new Label("Selected: -");

// Handle selection change.
table.addValueChangeListener(new Property.ValueChangeListener() {
    public void valueChange(ValueChangeEvent event) {
        current.setValue("Selected: " + table.getValue());
    }
});