Search in sources :

Example 81 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class NewUserRegistrationController method btnRegistration.

@FXML
private void btnRegistration(ActionEvent event) {
    if (txtName.getText().isEmpty() || countWords(txtName.getText()) == 0) {
        lblMsg1.setText("Write your name");
        txtName.clear();
    } else if (txtUsername.getText().isEmpty()) {
        lblMsg1.setText("Set a Username");
    } else if (passPassword.getText().isEmpty()) {
        lblMsg1.setText("Set a Password");
    } else if (!passPassword.getText().equals(passReTypePassword.getText())) {
        lblMsg1.setText("Re-type Password Correctly");
    } else if (txtAnswer.getText().isEmpty()) {
        lblMsg1.setText("Set a Security Question Answer");
    } else {
        boolean feedback = setUsername(txtUsername.getText());
        setUserFullName(txtName.getText());
        setPassword(passPassword.getText());
        setSecurityQuestion(cmboSecurityQuestion.getValue());
        setSecurityQuestionAnswer(txtAnswer.getText());
        Stage NewUserRegistrationStage = (Stage) btnRegistration.getScene().getWindow();
        (new GoToOperation()).goToSignIn(NewUserRegistrationStage);
        if (feedback) {
            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Created User Successfully");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText("Account Created Successfully");
            confirmationMsg.setX(NewUserRegistrationStage.getX() + 200);
            confirmationMsg.setY(NewUserRegistrationStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    confirmationMsg.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            confirmationMsg.showAndWait();
        } else {
            Alert confirmationMsg = new Alert(AlertType.ERROR);
            confirmationMsg.setTitle("Sign Up Failed");
            confirmationMsg.setHeaderText("Sign Up Failed");
            confirmationMsg.setContentText("There have some problem.");
            confirmationMsg.setX(NewUserRegistrationStage.getX() + 200);
            confirmationMsg.setY(NewUserRegistrationStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    confirmationMsg.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            confirmationMsg.showAndWait();
        }
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) GoToOperation(operation.GoToOperation) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Example 82 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class RegistrationIssueController method btnSave.

@FXML
private void btnSave(ActionEvent event) {
    if (passPassword.getText().isEmpty()) {
        lblMsgInformation.setText("Password can't empty");
    } else if (!passReTypePassword.getText().equals(passPassword.getText())) {
        lblMsgInformation.setText("Re-type Your Password Correctly");
    } else if (txtAnswer.getText().isEmpty() || countWords(txtAnswer.getText()) == 0) {
        lblMsgInformation.setText("Answer the Security Question.");
    } else {
        setPassword(passPassword.getText());
        setSecurityQuestion(cmboSecurityQuestion.getValue());
        setSecurityQuestionAnswer(txtAnswer.getText());
        Alert confirmationMsg = new Alert(AlertType.INFORMATION);
        confirmationMsg.setTitle("Operation Successful");
        confirmationMsg.setHeaderText(null);
        confirmationMsg.setContentText("Information Updated Successfully");
        Stage RegistrationIssueStage = (Stage) btnSave.getScene().getWindow();
        confirmationMsg.setX(RegistrationIssueStage.getX() + 200);
        confirmationMsg.setY(RegistrationIssueStage.getY() + 170);
        Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                confirmationMsg.hide();
            }
        }));
        idlestage.setCycleCount(1);
        idlestage.play();
        confirmationMsg.showAndWait();
        (new GoToOperation()).goToSignIn(RegistrationIssueStage);
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler) GoToOperation(operation.GoToOperation) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Example 83 with ActionEvent

use of javafx.event.ActionEvent in project Malai by arnobl.

the class BaseWIMPWidgetTest method testProcessEventGoodDataOnStart.

@Test
void testProcessEventGoodDataOnStart() {
    interaction.getFsm().addHandler(new InteractionHandlerStub() {

        @Override
        public void fsmStarts() {
            assertEquals(wimpWidget, interaction.getWidget());
        }
    });
    interaction.processEvent(new ActionEvent(wimpWidget, null));
    JfxtestHelper.waitForTimeoutTransitions();
}
Also used : ActionEvent(javafx.event.ActionEvent) Test(org.junit.jupiter.api.Test)

Example 84 with ActionEvent

use of javafx.event.ActionEvent in project Malai by arnobl.

the class TestMenuItemPressed method testProcessEventReinit.

@Test
void testProcessEventReinit() {
    interaction.processEvent(new ActionEvent(menuitem, null));
    assertNull(interaction.getWidget());
    assertTrue(interaction.getFsm().getCurrentState() instanceof InitState);
}
Also used : ActionEvent(javafx.event.ActionEvent) InitState(org.malai.fsm.InitState) Test(org.junit.jupiter.api.Test)

Example 85 with ActionEvent

use of javafx.event.ActionEvent in project Malai by arnobl.

the class TestMenuItemPressed method testProcessEventGoodData.

@Test
void testProcessEventGoodData() {
    interaction.getFsm().addHandler(new InteractionHandlerStub() {

        @Override
        public void fsmStops() {
            assertEquals(menuitem, interaction.getWidget());
        }
    });
    interaction.processEvent(new ActionEvent(menuitem, null));
}
Also used : ActionEvent(javafx.event.ActionEvent) Test(org.junit.jupiter.api.Test)

Aggregations

ActionEvent (javafx.event.ActionEvent)171 EventHandler (javafx.event.EventHandler)61 Stage (javafx.stage.Stage)52 KeyFrame (javafx.animation.KeyFrame)47 Timeline (javafx.animation.Timeline)47 FXML (javafx.fxml.FXML)44 Alert (javafx.scene.control.Alert)36 Button (javafx.scene.control.Button)35 Label (javafx.scene.control.Label)35 MenuItem (javafx.scene.control.MenuItem)33 ContextMenu (javafx.scene.control.ContextMenu)25 File (java.io.File)24 Insets (javafx.geometry.Insets)24 Scene (javafx.scene.Scene)24 List (java.util.List)21 ObservableList (javafx.collections.ObservableList)21 Node (javafx.scene.Node)20 TextField (javafx.scene.control.TextField)20 Optional (java.util.Optional)18 FXCollections (javafx.collections.FXCollections)18