Stage
A
두 개의 Button
s, oui
Button
opens a new Stage
B
, non
closes 를 포함 하는 a가 있다고 가정 해 보겠습니다 A
. 내가하려는 것은를 A
클릭 oui
Button
하고 연 후 닫는 것 B
입니다. 나는 showAndWait()
열기 위해 사용 하고 있으며 B
, 닫기 전에 실행하려고 할 때 A.close()
분명히 실패하는 것을 showAndWait()
실행하려고 시도했지만 s 및 s를 포함한 모든 컨트롤 이 비활성화되면 해결 방법이 있습니까?A.close()
showAndWait()
A
B
Button
Text Field
oui
열기 위해 클릭 할 때 실행되는 코드는 다음과 같습니다 B
Stage
.
public class AController implements Initializable {
@FXML
private Button oui;
@FXML
private Button non;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
@FXML
private void ouiBtnClick(ActionEvent event) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("B.fxml"));
Stage stage = new Stage();
VBox mainPane = (VBox) loader.load();
Scene scene = new Scene(mainPane);
stage.setScene(scene);
stage.initStyle(StageStyle.DECORATED);
stage.setResizable(false);
stage.showAndWait();
nonBtnClick(); // method that close `A`
}
@FXML
private void nonBtnClick() {
Stage s = (Stage) non.getScene().getWindow();
s.close();
}
}
사용 show
하는 대신 showAndWait
트릭을했다. Sedrick Jefferson의 의견에 감사드립니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다