Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.fxml.FXMLLoader;
- import javafx.stage.Stage;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.scene.layout.BorderPane;
- public class Main extends Application {
- @Override
- public void start(Stage primaryStage) {
- try {
- Parent root=FXMLLoader.load(getClass().getResource("/application/Login.fxml"));
- Scene scene = new Scene(root,400,400);
- scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
- primaryStage.setScene(scene);
- primaryStage.show();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- public static void main(String[] args) {
- launch(args); // tried changing this to string[0] didnt work
- }
- }
- package application;
- import java.awt.Label;
- import java.awt.TextField;
- import java.awt.event.ActionEvent;
- import javafx.fxml.FXML;
- public class MainController {
- @FXML
- private Label LblStatus;
- @FXML
- private TextField TxtUsername;
- @FXML
- private TextField TxtPassword;
- public void Login(ActionEvent event)
- {
- LblStatus.setText("Login sucsess");
- }
- }
- login page
- <?xml version="1.0" encoding="UTF-8"?>
- <?import java.lang.*?>
- <?import javafx.scene.control.*?>
- <?import javafx.scene.layout.*?>
- <?import javafx.scene.layout.AnchorPane?>
- <?import javafx.scene.text.*?>
- <AnchorPane prefHeight="400.0" prefWidth="500.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="application.MainController">
- <!-- TODO Add Nodes -->
- <children>
- <Pane prefHeight="400.0" prefWidth="500.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
- <children>
- <TitledPane animated="false" layoutX="0.0" layoutY="0.0" prefHeight="400.0000999999975" prefWidth="500.0" text="LOGIN FORM" textAlignment="CENTER" wrapText="false">
- <content>
- <AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
- <children>
- <TextField fx:id="TxtUsername" layoutX="227.0" layoutY="129.0" prefWidth="200.0" promptText="Enter Username" />
- <Label layoutX="129.0" layoutY="129.0" prefWidth="98.0" text="USERNAME:">
- <font>
- <Font size="15.0" fx:id="x1" />
- </font>
- </Label>
- <Label font="$x1" layoutX="129.0" layoutY="183.0" prefWidth="98.0" text="PASSWORD:" />
- <Button font="$x1" layoutX="224.0" layoutY="225.0" mnemonicParsing="false" onAction="#Login" text="LOGIN" />
- <PasswordField fx:id="TxtPassword" layoutX="224.0" layoutY="183.0" prefWidth="200.0" promptText="Enter Password" />
- <Label id="Status" fx:id="LblStatus" layoutX="259.0" layoutY="69.0" text="Status">
- <font>
- <Font size="20.0" />
- </font>
- </Label>
- </children>
- </AnchorPane>
- </content>
- <font>
- <Font name="Arial Black" size="15.0" />
- </font>
- </TitledPane>
- </children>
- </Pane>
- </children>
- </AnchorPane>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement