Advertisement
Guest User

Untitled

a guest
Apr 15th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.fxml.FXMLLoader;
  3. import javafx.stage.Stage;
  4. import javafx.scene.Parent;
  5. import javafx.scene.Scene;
  6. import javafx.scene.layout.BorderPane;
  7.  
  8.  
  9. public class Main extends Application {
  10. @Override
  11. public void start(Stage primaryStage) {
  12. try {
  13. Parent root=FXMLLoader.load(getClass().getResource("/application/Login.fxml"));
  14. Scene scene = new Scene(root,400,400);
  15. scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
  16. primaryStage.setScene(scene);
  17. primaryStage.show();
  18. } catch(Exception e) {
  19. e.printStackTrace();
  20. }
  21. }
  22.  
  23. public static void main(String[] args) {
  24. launch(args); // tried changing this to string[0] didnt work
  25. }
  26. }
  27.  
  28. package application;
  29.  
  30. import java.awt.Label;
  31. import java.awt.TextField;
  32. import java.awt.event.ActionEvent;
  33.  
  34. import javafx.fxml.FXML;
  35.  
  36. public class MainController {
  37.  
  38. @FXML
  39. private Label LblStatus;
  40. @FXML
  41. private TextField TxtUsername;
  42. @FXML
  43. private TextField TxtPassword;
  44. public void Login(ActionEvent event)
  45. {
  46.  
  47. LblStatus.setText("Login sucsess");
  48. }
  49. }
  50.  
  51. login page
  52.  
  53. <?xml version="1.0" encoding="UTF-8"?>
  54.  
  55. <?import java.lang.*?>
  56. <?import javafx.scene.control.*?>
  57. <?import javafx.scene.layout.*?>
  58. <?import javafx.scene.layout.AnchorPane?>
  59. <?import javafx.scene.text.*?>
  60.  
  61. <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">
  62. <!-- TODO Add Nodes -->
  63. <children>
  64. <Pane prefHeight="400.0" prefWidth="500.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
  65. <children>
  66. <TitledPane animated="false" layoutX="0.0" layoutY="0.0" prefHeight="400.0000999999975" prefWidth="500.0" text="LOGIN FORM" textAlignment="CENTER" wrapText="false">
  67. <content>
  68. <AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
  69. <children>
  70. <TextField fx:id="TxtUsername" layoutX="227.0" layoutY="129.0" prefWidth="200.0" promptText="Enter Username" />
  71. <Label layoutX="129.0" layoutY="129.0" prefWidth="98.0" text="USERNAME:">
  72. <font>
  73. <Font size="15.0" fx:id="x1" />
  74. </font>
  75. </Label>
  76. <Label font="$x1" layoutX="129.0" layoutY="183.0" prefWidth="98.0" text="PASSWORD:" />
  77. <Button font="$x1" layoutX="224.0" layoutY="225.0" mnemonicParsing="false" onAction="#Login" text="LOGIN" />
  78. <PasswordField fx:id="TxtPassword" layoutX="224.0" layoutY="183.0" prefWidth="200.0" promptText="Enter Password" />
  79. <Label id="Status" fx:id="LblStatus" layoutX="259.0" layoutY="69.0" text="Status">
  80. <font>
  81. <Font size="20.0" />
  82. </font>
  83. </Label>
  84. </children>
  85. </AnchorPane>
  86. </content>
  87. <font>
  88. <Font name="Arial Black" size="15.0" />
  89. </font>
  90. </TitledPane>
  91. </children>
  92. </Pane>
  93. </children>
  94. </AnchorPane>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement