Skip to content
Snippets Groups Projects
Commit 7c04aa46 authored by Nicolay Schiøll-Johansen's avatar Nicolay Schiøll-Johansen
Browse files

Press Enter to log in

parent 5feabe8d
No related branches found
No related tags found
1 merge request!165Weekly merge to Master
......@@ -3,11 +3,15 @@ package NTNU.IDATT1002.controllers;
import NTNU.IDATT1002.App;
import NTNU.IDATT1002.service.UserService;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.text.Text;
import javax.persistence.EntityManager;
import java.io.IOException;
......@@ -40,12 +44,12 @@ public class Login {
App.setRoot("signup");
}
/**
* Method that changes scene to Main page
* @param actionEvent
* @throws IOException
*/
public void login(ActionEvent actionEvent) throws IOException {
public void login() throws IOException {
String username = Username.getText();
String password = Password.getText();
if(userService.logIn(username, password)) {
......@@ -59,4 +63,15 @@ public class Login {
error_msg.setText("Incorrect username or password");
}
}
public void enterLogin(KeyEvent keyEvent) throws IOException {
if(keyEvent.getCode().equals(KeyCode.ENTER)){
login();
}
}
public void buttonLogin(ActionEvent event) throws IOException {
login();
}
}
......@@ -5,7 +5,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<VBox alignment="CENTER" prefHeight="1080.0" prefWidth="1920.0" spacing="20.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="NTNU.IDATT1002.controllers.Login">
<VBox alignment="CENTER" prefHeight="1080.0" prefWidth="1920.0" spacing="20.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="NTNU.IDATT1002.controllers.Login">
<children>
<Label text="Login Page" />
<GridPane hgap="10.0" maxWidth="339.0" prefHeight="98.0" prefWidth="339.0" vgap="10.0">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment