0
我正在嘗試使用javafx創建一個Gluon移動應用程序。我想創建一個登錄頁面,在成功登錄的時候,我需要在點擊按鈕中加載另一個(第二視圖)視圖。我沒有得到一個適當的例子。如果有人知道這一點,請幫助。我有兩個視圖主要演示者和輔助演示者(帶FXML的膠子應用程序).Below是我的主要視圖的控制器。如何在使用javafx的Gluon移動應用程序中切換視圖?
public class PrimaryPresenter {
@FXML
private View primary;
private Label label;
@FXML
private TextField username;
@FXML
private Button loginBt;
private Alert alert;
@FXML
private PasswordField password;
public void initialize() {
primary.showingProperty().addListener((obs, oldValue, newValue) -> {
if (newValue) {
AppBar appBar = MobileApplication.getInstance().getAppBar();
appBar.setNavIcon(MaterialDesignIcon.MENU.button(e
-> MobileApplication.getInstance().showLayer(ArjunsApp.MENU_LAYER)));
appBar.setTitleText("Primary");
appBar.getActionItems().add(MaterialDesignIcon.SEARCH.button(e
-> System.out.println("Search")));
}
});
}
@FXML
private void buttonClick(ActionEvent event) {
if(username.getText().equals("")){
alert = new Alert(AlertType.ERROR,"Enter username");
alert.showAndWait();
}else if(password.getText().equals("")){
alert = new Alert(AlertType.ERROR,"Enter password");
alert.showAndWait();
}else{
//Code to load my secondary view
}
}
}
它工作正常。謝謝@Jose Pereda –
好吧,考慮將答案標記爲已接受(在左側打勾),以便對其他人也有用。 –