public class PopupController {
public ListView<String> listView;
public Button addWalletButton;
public PieChart piechart;
public Label size;
private WalletModel walletModel = Factory.inject(WalletModel.class);
@FXML
public void initialize() throws IOException {
listView.setCellFactory(param -> new EditableCell());
addWalletButton.setOnMouseClicked(event -> {
walletModel.CreateWallet();
listView.getFixedCellSize();
listView.getItems().add("Wallet " + walletModel.WalletSize());
size.setText("Total Wallets: " + walletModel.WalletSize());
});
size.setText("Wallet Size " + walletModel.WalletSize());
listView.getItems().add("Wallet 1");
}
private class EditableCell extends ListCell<String>{
private final TextField textField;
EditableCell() throws IOException {
textField = new TextField();
setGraphic(FXMLLoader.load(getClass().getResource("/selectbutton.fxml")));
}
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if(empty){
textField.setVisible(false);
}
else{
textField.setVisible(true);
textField.setText(item);
}
}
}
}
它在initialize()方法的第一条语句中显示错误。
我试图通过按钮(“添加钱包”)将fxml
文件放在列表元素上。我在下面附加了我的fxml
代码。
我没有收到stacktrace,因为它显示了编译错误
<AnchorPane prefHeight="27.0" prefWidth="69.0" xmlns="http://javafx.com/javafx/8.0.121"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.gazman.coco.desktop.controllers.PopupController">
<Button fx:id="select" layoutX="6.0" layoutY="2.0" mnemonicParsing="false" text="Button"/>
</AnchorPane>