버튼을 클릭하여 새 단계의 구성 요소를 비활성화하지 않고 새 단계를 표시 할 때 현재 단계를 닫는 방법

Ammar Akouri

Stage A두 개의 Buttons, oui Buttonopens a new Stage B, noncloses 를 포함 하는 a가 있다고 가정 해 보겠습니다 A. 내가하려는 것은를 A클릭 oui Button하고 연 닫는 B입니다. 나는 showAndWait()열기 위해 사용 하고 있으며 B, 닫기 전에 실행하려고 할 때 A.close()분명히 실패하는 것을 showAndWait()실행하려고 시도했지만 s 및 s를 포함한 모든 컨트롤 이 비활성화되면 해결 방법이 있습니까?A.close()showAndWait() ABButtonText 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();
    }

}
Ammar Akouri

사용 show하는 대신 showAndWait트릭을했다. Sedrick Jefferson의 의견에 감사드립니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관