Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.Scene;
- import javafx.scene.control.*;
- import javafx.scene.effect.DropShadow;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import javafx.scene.layout.AnchorPane;
- import javafx.scene.layout.BorderPane;
- import javafx.scene.layout.GridPane;
- import javafx.scene.layout.StackPane;
- import javafx.scene.paint.Color;
- import javafx.scene.shape.Line;
- import javafx.scene.shape.Rectangle;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- public class LoginScene extends Application {
- public static void main(String[] args) {
- launch(args);
- }
- @Override
- public void start(Stage stage) {
- //1. pane
- StackPane stackPane = new StackPane();
- //Scene
- Scene scene = new Scene(stackPane,700,450);
- //2. pane
- BorderPane borderPaneRectangle = new BorderPane();
- //3. pane
- BorderPane borderPane = new BorderPane();
- //4. pane
- GridPane gridPane = new GridPane();
- gridPane.setHgap(10);
- gridPane.setVgap(2);
- gridPane.setAlignment(Pos.CENTER);
- //5. pane
- GridPane gridPaneHeader = new GridPane();
- gridPaneHeader.setVgap(10);
- gridPaneHeader.setHgap(10);
- gridPaneHeader.setAlignment(Pos.CENTER);
- //6. pane
- BorderPane borderPaneHeader = new BorderPane();
- borderPaneHeader.setCenter(gridPaneHeader);
- //Text header and dropShadow
- DropShadow ds = new DropShadow();
- ds.setOffsetY(5.0f);
- ds.setColor(Color.color(0.2f, 0.2f, 0.2f));
- Text text = new Text("Greve Kyokushin Karate");
- text.setId("text_header");
- text.setEffect(ds);
- text.setCache(true);
- //Logos
- ImageView logo = new ImageView(new Image(getClass().getResourceAsStream("logo.jpg")));
- ImageView calligraphy = new ImageView(new Image(getClass().getResourceAsStream("kaligrafi.jpg")));
- logo.setFitHeight(75);
- logo.setFitWidth(75);
- calligraphy.setFitWidth(50);
- calligraphy.setFitHeight(75);
- AnchorPane anchorPaneLogo = new AnchorPane();
- AnchorPane anchorPaneCalligraphy = new AnchorPane();
- AnchorPane.setLeftAnchor(logo, 20d);
- AnchorPane.setTopAnchor(logo, 20d);
- AnchorPane.setTopAnchor(calligraphy, 20d);
- AnchorPane.setRightAnchor(calligraphy,20d);
- anchorPaneLogo.getChildren().add(logo);
- anchorPaneCalligraphy.getChildren().add(calligraphy);
- //Labels username and password
- Label label_username = new Label(" Brugernavn:");
- Label label_password = new Label(" Kodeord:");
- //Field for username and password
- TextField textField_username = new TextField();
- textField_username.setPromptText("123@gmail.com");
- PasswordField passwordField_password = new PasswordField();
- passwordField_password.setPromptText("*********");
- //Button for login
- Button button_login = new Button("Log ind");
- button_login.setId("button_login");
- //Lines between nodes in gridPane
- Line line1 = new Line();
- line1.setStartX(0);
- line1.setEndX(400);
- Line line2 = new Line();
- line2.setStartX(0);
- line2.setEndX(400);
- //Rectangle behind the gridPane
- Rectangle rectangle = new Rectangle(500,200);
- rectangle.setArcHeight(25);
- rectangle.setArcWidth(25);
- rectangle.setId("rectangle");
- //Adding to gridPane for login
- //Adding extra space
- gridPane.setMargin(label_username, new Insets(90,0,0,0));
- gridPane.setMargin(textField_username, new Insets(90,0,0,0));
- gridPane.add(label_username,1,1,1,1);
- gridPane.add(textField_username,2,1,1,1);
- gridPane.add(line1,1,2,2,1);
- //Adding extra space
- gridPane.setMargin(label_password, new Insets(10,0,0,0));
- gridPane.setMargin(passwordField_password, new Insets(10,0,0,0));
- gridPane.add(label_password,1,3);
- gridPane.add(passwordField_password,2,3);
- gridPane.add(line2,1,4,2,1);
- //Adding extra space between button_login and the black line
- gridPane.setMargin(button_login, new Insets(25,0,0,0));
- gridPane.add(button_login,1,5,2,1);
- //Adding to gridPaneHeader
- //Adding extra space from the top of the window
- gridPane.setMargin(text, new Insets(50,0,0,0));
- gridPaneHeader.add(text,2,1);
- //Adding panes to panes
- borderPaneRectangle.setCenter(rectangle);
- borderPaneRectangle.setTop(borderPaneHeader);
- borderPane.setCenter(gridPane);
- stackPane.getChildren().addAll(borderPaneRectangle, borderPane, anchorPaneLogo, anchorPaneCalligraphy);
- // Adding the title to the window (stage)
- stage.setTitle("Log ind");
- // Removing resize
- stage.setResizable(false);
- // Adding stylesheet
- scene.getStylesheets().add("Stylesheet.css");
- return scene;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement