2
Good evening guys, I’m wanting to implement a login screen with the following fields, but it does not appear the other fields, appears the user field and password
Forgot the login click here:________ Forgot password click here:________ Usuario:___________ Password:_____________
Students Botao(register)
Pofessores or employees Botao(register)
Follows an image for better understanding:
Follow the screen code:
package Teste;
import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class LoginApp extends Application {
@Override
public void start(Stage stage) throws Exception {
stage.setTitle("Sitema de Gerenciamento Academico");
AnchorPane pane = new AnchorPane();
pane.setPrefSize(700, 400);
TextField txLogin = new TextField();
Scene scene = new Scene(pane);
Group root = new Group();
GridPane gridpane = new GridPane();
gridpane.setPadding(new Insets(5));
//gridpane.setHgap(10);
//gridpane.setVgap(10);
Label label = new Label("Esqueceu o login? Clique aqui para recuperá-lo. "
+ "Esqueceu a senha? Clique aqui para recuperá-la.");
GridPane.setHalignment(label, HPos.CENTER);
gridpane.add(label, 0, 0);
root.getChildren().add(gridpane);
//stage.setScene(scene);
txLogin.setPromptText("Digite aqui seu login");
PasswordField txSenha = new PasswordField();
txSenha.setPromptText("Digite aqui sua senha");
Button btEntrar = new Button("Entrar");
Button btSair = new Button("Sair");
pane.getChildren().addAll(txLogin, txSenha, btEntrar, btSair);
stage.setScene(scene);
stage.show();
txLogin.setLayoutX((pane.getWidth() - txLogin.getWidth()) / 2);
txLogin.setLayoutY(50);
txSenha.setLayoutX((pane.getWidth() - txSenha.getWidth()) / 2);
txSenha.setLayoutY(100);
btEntrar.setLayoutX(
(pane.getWidth() - btEntrar.getWidth()) / 2);
btEntrar.setLayoutY(150);
btSair.setLayoutX((pane.getWidth() - btSair.getWidth()) / 2);
btSair.setLayoutY(200);
//pane.setStyle("-fx-background-color: linear-gradient(from 0% 0% to 100% 100%, blue 0%, silver 100%);");
}
public static void main(String[] args) {
launch(args);
}
}
Some comments on the code was made to test and see that it worked as described above but did not work. I thank you for your help..