public static <T> Updatable disableWhenNoSelection(@NotNull JButton button, @NotNull JList<T> list) {
    class MyListSelectionListener extends Updatable implements ListSelectionListener {
      MyListSelectionListener(JButton button) {
        super(button);
      }

      @Override
      public void valueChanged(ListSelectionEvent e) {
        setButtonEnabled((list.getSelectedIndex() != -1));
      }

      @Override
      public void update() {
        valueChanged(null);
      }
    }
    MyListSelectionListener listener = new MyListSelectionListener(button);
    list.getSelectionModel().addListSelectionListener(listener);
    listener.update();
    return listener;
  }
public static <T> Updatable disableWhenNoSelection(@NotNull JButton button, @NotNull JList<T> list)