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下面附上了我的代码。我没有收到堆栈跟踪,因为它显示编译错误<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>
1 回答
长风秋雁
TA贡献1757条经验 获得超7个赞
IOException
是一个受检异常,这意味着它必须通过以下两种方式之一进行显式处理:
夹在语句的
catch
子句中try-catch
通过可能发生例外的方法传播。这是通过添加
throws IOException
到方法签名的末尾来完成的。
这是为了迫使开发人员在合理预期外部故障的情况下处理 IO 和其他操作的典型故障。
添加回答
举报
0/150
提交
取消