如何在JavaFx中将数据添加到ListView

时间:2019-12-18 02:21:59

标签: java listview javafx arraylist javafx-8

单击按钮后,我试图将Arraylist中的数据添加到javaFx列表视图中,但是由于出现错误,因此由于某些原因它不起作用,它在调试消息屏幕中显示有数据,但未在列表视图中显示它们!

任何帮助将不胜感激!

MainController类:

public class MainController {

walletDAO dao = new walletDAO();
ArrayList<wallet> allwallets = new ArrayList<wallet>();


@FXML
private Label message;
private ListView<ArrayList<wallet>> list;

public void getTags(ActionEvent event) throws SQLException {

allwallets = dao.getWalletTag();
System.out.println(allwallets);
list.getItems().add(allwallets);

}
}

错误消息:

Retrieve all tags
SELECT Tag FROM wallets;
[rfid2, rfid3]
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: 
java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at 

0 个答案:

没有答案