Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import javafx.application.Application;
- import javafx.scene.layout.GridPane;
- import javafx.stage.Stage;
- import java.awt.*;
- public class Main extends Application {
- Stage window;
- public static void main(String[] args){
- launch(args);
- }
- @Override
- public void start(Stage primaryStage) throws Exception {
- window = primaryStage;
- window.setTitle("Learn from the Book");
- window.setScene(new LoginScene());
- window.setMinWidth(320);
- window.setMinHeight(240);
- window.show();
- }
- }
- */
- public class LoginScene extends Scene{
- GridPane grid = new GridPane();
- GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
- private double scale = 0.3;
- private double width = gd.getDisplayMode().getWidth() * scale ;
- private double height = gd.getDisplayMode().getHeight() * scale;
- public LoginScene(){
- super(new GridPane(),100,100);
- setGridLogin();
- }
- private void setGridLogin(){
- grid.setPadding(new Insets(10));
- grid.setAlignment(Pos.CENTER);
- grid.setVgap(8);
- grid.setHgap(10);
- Label nameLabel = new Label("Username:");
- GridPane.setConstraints(nameLabel,0,0);
- Label passLabel = new Label("Password:");
- GridPane.setConstraints(passLabel,0,1);
- TextField nameInput = new TextField();
- nameInput.setPromptText("username");
- GridPane.setConstraints(nameInput,1,0);
- TextField passInput = new TextField();
- passInput.setPromptText("password");
- GridPane.setConstraints(passInput,1,1);
- Button loginButton = new Button("Log in");
- GridPane.setConstraints(loginButton,1,2);
- //loginButton.setOnAction(e -> switchScene(passInput.getText(),nameInput.getText()));
- grid.getChildren().addAll(nameLabel,nameInput,passInput,passLabel,loginButton);
- Scene scene = new Scene(grid,width,height);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement