Dummy login dialog

This commit is contained in:
Paul Schaub 2018-08-20 21:33:24 +02:00
parent 77c8782026
commit db64ab29d6
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
5 changed files with 65 additions and 50 deletions

View file

@ -1,60 +1,18 @@
package de.vanitasvitae.fasel.sample;
import java.io.IOException;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
public class LoginController {
public class LoginController extends Controller {
@FXML
private JFXTextField text_username;
@FXML
private JFXPasswordField text_password;
@FXML
private JFXButton button_login;
private Main main;
private LoginFragmentController loginFragmentController;
@FXML
private void initialize() {
button_login.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
String username = text_username.getText();
String password = text_password.getText();
try {
switchToMainScene();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
private void switchToMainScene() throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/fxml/sample.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root, 1200, 741);
main.getPrimaryStage().setTitle("Hello World");
main.getPrimaryStage().setScene(scene);
// primaryStage.show();
}
public void setApplication(Main main) {
this.main = main;
loginFragmentController.setApplication(main);
}
}

View file

@ -0,0 +1,59 @@
package de.vanitasvitae.fasel.sample;
import java.io.IOException;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
public class LoginFragmentController {
@FXML
private JFXTextField text_username;
@FXML
private JFXPasswordField text_password;
@FXML
private JFXButton button_login;
private Main main;
@FXML
private void initialize() {
button_login.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
String username = text_username.getText();
String password = text_password.getText();
try {
switchToMainScene();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
private void switchToMainScene() throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/fxml/sample.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root, 1200, 741);
main.getPrimaryStage().setTitle("Hello World");
main.getPrimaryStage().setScene(scene);
// primaryStage.show();
}
public void setApplication(Main main) {
this.main = main;
}
}

View file

@ -15,9 +15,7 @@ public class Main extends Application {
this.primaryStage = primaryStage;
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/fxml/layout/login.fxml"));
Parent root = loader.load();
loader.setLocation(getClass().getResource("/fxml/fragment/login.fxml"));
LoginController controller = loader.getController();
controller.setApplication(this);
Scene scene = new Scene(root, 1200, 741);

View file

@ -6,7 +6,7 @@
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.VBox?>
<VBox prefWidth="300.0" prefHeight="150.0" minWidth="300.0" minHeight="150.0" maxWidth="300.0" maxHeight="150.0" fx:controller="de.vanitasvitae.fasel.sample.LoginController"
<VBox prefWidth="300.0" prefHeight="150.0" minWidth="300.0" minHeight="150.0" maxWidth="300.0" maxHeight="150.0" fx:controller="de.vanitasvitae.fasel.sample.LoginFragmentController"
alignment="CENTER" spacing="8.0" styleClass="card" stylesheets="@../../css/material/cards.css" xmlns="http://javafx.com/javafx/8.0.162-ea" xmlns:fx="http://javafx.com/fxml/1">
<children>
<JFXTextField fx:id="text_username" promptText="Username" />

View file

@ -3,8 +3,8 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="CENTER" style="-fx-background-color: lightgrey;" xmlns="http://javafx.com/javafx/8.0.162-ea" xmlns:fx="http://javafx.com/fxml/1" >
<VBox alignment="CENTER" style="-fx-background-color: lightgrey;" xmlns="http://javafx.com/javafx/8.0.162-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.vanitasvitae.fasel.sample.LoginController">
<HBox alignment="CENTER" style="-fx-background-color: transparent;">
<fx:include source="../fragment/login.fxml" />
<fx:include fx:id="loginFragment" source="../fragment/login.fxml" />
</HBox>
</VBox>