我想從另一個類中找到一種方法來訪問我的主JavaFx類中的階段,所以我可以對它執行一些操作,但是我不能,因爲它作爲參數傳遞像這樣:如何通過一個JavaFx初級階段
@Override
public void start(final Stage primaryStage) {
的WakiliProject
類全:
public class WakiliProject extends Application {
@Override
public void start(final Stage primaryStage) {
Group root = new Group();
StageDraggable.stageDraggable(root, primaryStage);
root.getChildren().addAll(mainContainer);
Scene scene = new Scene(root, 900, 654);
primaryStage.setScene(scene);
primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.setTitle("Wakili");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
我如何能趕上從另一個類在上述階段primaryStage
就像我在初始化階段'公共舞臺newTryEMail後做下面做一些動作;':
public class TryEMailController implements Initializable {
// Initializes the controller class.
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
public Stage newTryEMail;
public void newTryEMailStage() throws IOException {
newTryEMail = new Stage();
newTryEMail.initModality(Modality.WINDOW_MODAL);
newTryEMail.initOwner(AddNewEmailController.newComposeNewEmail);
Parent newTryEMailRoot = FXMLLoader.load(getClass().getResource("/wakiliproject/Forms/AddNew/NewEmail/TryEMailController.fxml"));
StageDraggable.stageDraggable(newTryEMailRoot, newTryEMail);
Scene newComposeNewEmailScene = new Scene(newTryEMailRoot, 590, 670);
newTryEMail.setScene(newComposeNewEmailScene);
newTryEMail.show();
}
}
來自另一個類叫TryEMailController
?
謝謝大家提前。
請你介意說明這一點。我試圖在另一個類中使用'primaryStage' – ILikeProgramming