Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pt.europeia.casa_inteligente.controller;
- import java.io.IOException;
- import javafx.event.ActionEvent;
- import javafx.fxml.FXML;
- import javafx.fxml.FXMLLoader;
- import javafx.scene.Scene;
- import javafx.scene.control.Label;
- import javafx.scene.control.PasswordField;
- import javafx.scene.control.TextField;
- import javafx.scene.layout.AnchorPane;
- import javafx.stage.Stage;
- import pt.europeia.casa_inteligente.Main;
- public class LoginController {
- @FXML
- private AnchorPane ap;
- @FXML
- private TextField username;
- @FXML
- private PasswordField password;
- @FXML
- private Label msgErro;
- @FXML
- /**
- * Método para mudar da view Login para a view Welcome
- * @param event
- * @throws IOException
- */
- private void mudarView(ActionEvent event) throws IOException{
- Stage stage = new Stage();
- Stage prevStage = (Stage) ap.getScene().getWindow();
- FXMLLoader loader = new FXMLLoader();
- loader.setLocation(Main.class.getResource("views/welcome.fxml"));
- Scene scene = new Scene(loader.load());
- stage.setScene(scene);
- prevStage.close();
- stage.show();
- }
- @FXML
- /**
- * Método para verificar se username e password estão corretos
- * @param event
- * @throws IOException
- */
- private void login(ActionEvent event) throws IOException{
- if(username.getText().equals("root") && password.getText().equals("root")){
- mudarView(event);
- }
- else{
- msgErro.setVisible(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement