Dummy login dialog
This commit is contained in:
parent
77c8782026
commit
db64ab29d6
5 changed files with 65 additions and 50 deletions
|
@ -1,60 +1,18 @@
|
||||||
package de.vanitasvitae.fasel.sample;
|
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.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
|
@FXML
|
||||||
private JFXTextField text_username;
|
private LoginFragmentController loginFragmentController;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private JFXPasswordField text_password;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private JFXButton button_login;
|
|
||||||
|
|
||||||
private Main main;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void initialize() {
|
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) {
|
public void setApplication(Main main) {
|
||||||
this.main = main;
|
loginFragmentController.setApplication(main);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,9 +15,7 @@ public class Main extends Application {
|
||||||
this.primaryStage = primaryStage;
|
this.primaryStage = primaryStage;
|
||||||
FXMLLoader loader = new FXMLLoader();
|
FXMLLoader loader = new FXMLLoader();
|
||||||
loader.setLocation(getClass().getResource("/fxml/layout/login.fxml"));
|
loader.setLocation(getClass().getResource("/fxml/layout/login.fxml"));
|
||||||
|
|
||||||
Parent root = loader.load();
|
Parent root = loader.load();
|
||||||
loader.setLocation(getClass().getResource("/fxml/fragment/login.fxml"));
|
|
||||||
LoginController controller = loader.getController();
|
LoginController controller = loader.getController();
|
||||||
controller.setApplication(this);
|
controller.setApplication(this);
|
||||||
Scene scene = new Scene(root, 1200, 741);
|
Scene scene = new Scene(root, 1200, 741);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<?import com.jfoenix.controls.JFXTextField?>
|
<?import com.jfoenix.controls.JFXTextField?>
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?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">
|
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>
|
<children>
|
||||||
<JFXTextField fx:id="text_username" promptText="Username" />
|
<JFXTextField fx:id="text_username" promptText="Username" />
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?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;">
|
<HBox alignment="CENTER" style="-fx-background-color: transparent;">
|
||||||
<fx:include source="../fragment/login.fxml" />
|
<fx:include fx:id="loginFragment" source="../fragment/login.fxml" />
|
||||||
</HBox>
|
</HBox>
|
||||||
</VBox>
|
</VBox>
|
||||||
|
|
Loading…
Reference in a new issue