지난 일간 JavaFX에서만 작업했지만 목록보기를 채울 때 널 포인터 예외가 발생하는 것 같습니다.JavaFx NullPointer ListView를 채울 때 예외가 발생했습니다.
기본적으로 로그인 양식이 있으며 사용자가 로그인하면 새로운 .fxml 양식이로드되고 내부에 목록보기가있는 아코디언이 포함됩니다.
일단 사용자가 로그인 버튼을 클릭하면 목록보기를 채우고 싶습니다. 디버깅은 AccountMenu가 null임을 보여 주지만 그 이유는 알 수 없습니다. 누구든지 올바른 방향으로 나를 가리킬 수 있습니까?
감사 fxml 파일의
public class Controller {
@FXML
ListView<String> AccountMenu;
void Login(ActionEvent event) {
try {
ObservableList<String> items =FXCollections.observableArrayList (
"Item one","Item two");
AccountMenu.setItems(items);
}catch(Exception e){
e.printStackTrace();
}
}
부 :
<Accordion layoutY="136.0" prefHeight="768.0" prefWidth="210.0">
<panes>
<TitledPane id="MyAccount" animated="false" text="My account">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<ListView id="AccountMenu" fx:id="AccountMenu" layoutX="-1.0" prefHeight="658.0" prefWidth="210.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" style="-fx-background-color: red;" text="Books">
먼저 자바 코딩 스타일을 따라야합니다. 속성은 소문자로 시작해야합니다. – user3679868