解决方法
用列表视图说这样:
ListView<String> listView =new ListView<String>();
从ListView中获取选定的元素:
listView.getSelectionModel().getSelectedItem();
跟踪(聆听)列表视图选择中的更改:
listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable,String oldValue,String newValue) { System.out.println("ListView selection changed from oldValue = " + oldValue + " to newValue = " + newValue); } });