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 –
好吧,考虑将答案标记为已接受(在左侧打勾),以便对其他人也有用。 –