새 창을 여는 데 사용할 런처 클래스가 있습니다. 런처 주에서 서브 디렉토리에서 FXML을 부풀림
, 내가 전화 해요 :ChatList chatList = new ChatList(communicator);
ChatList의 생성자는 호출 나는 FXML 문서 팽창하려고 방법 showChatList()
: 난 그러나
private void showChatList() {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("fxml/ChatList.fxml"));
Parent root = (Parent) fxmlLoader.load();
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
을 내가 fxmlLoader.load()
라고 부를 곳인 java.lang.IllegalStateException: Location is not set.
을 얻는다. 다음과 같이 내 프로젝트 파일 구조는 다음과 같습니다 나는 FXML 파일에 대한 절대 파일 경로에서 퍼팅 시도하지만 여전히 운이 없었습니다
.
JavaFX에서 FXML을 (여러 단계로) 부 풀리는 것의 일반적인 원리를 이해하거나 나를 만날 수있는 좋은 리소스를 알려줄 수있는 사람이 있습니까?
건배.
이것이 도움이되는지 확신 할 수 없지만 새로운 FXMLLoader (getClass(). getClassLoader(). getResource (// path);)를 시도해야합니다. –
그래서이 말을하는 것입니다. :'FXMLLoader fxmlLoader = 새로운 FXMLLoader (getClass(). getResour ce ("// fxml/ChatList.fxml"));'? 그것은 여전히 작동하지 않습니다. –