Emon766

1stCodeCT1

Nov 24th, 2021 (edited)
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1.  
  2. //Main file
  3.  
  4. package javafxdemo;
  5.  
  6.  
  7. import javafx.application.Application;
  8.  
  9. import javafx.fxml.FXMLLoader;
  10. import javafx.scene.Parent;
  11. import javafx.scene.Scene;
  12.  
  13. import javafx.stage.Stage;
  14.  
  15. public class Main2 extends Application{
  16. int abc = 0;
  17.  
  18.  
  19. @Override
  20. public void start(Stage stage) throws Exception {
  21. Parent root = FXMLLoader.load(getClass().getResource("FXML.fxml"));
  22. Scene scene = new Scene(root);
  23. stage.setScene(scene);
  24. stage.setTitle("Signup Page");
  25. stage.show();
  26. }
  27. public static void main(String[] args) {
  28. launch(args);
  29. }
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36. //conltroller
  37.  
  38. package javafxdemo;
  39.  
  40. import java.net.URL;
  41. import java.util.ResourceBundle;
  42. import javafx.event.ActionEvent;
  43. import javafx.fxml.FXML;
  44. import javafx.fxml.Initializable;
  45. import javafx.scene.Parent;
  46. import javafx.scene.control.Button;
  47. import javafx.scene.control.Label;
  48. import javafx.scene.control.PasswordField;
  49. import javafx.scene.control.TextArea;
  50.  
  51.  
  52. public class FXMLController implements Initializable {
  53.  
  54. static Parent load() {
  55. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  56. }
  57. @FXML
  58. private Label lbl;
  59. @FXML
  60. private Button submit;
  61. @FXML
  62. private TextArea email;
  63. @FXML
  64. private TextArea username;
  65. @FXML
  66. private PasswordField password;
  67. @FXML
  68. private PasswordField password2;
  69.  
  70.  
  71. /**
  72. * Initializes the controller class.
  73. */
  74. @Override
  75. public void initialize(URL url, ResourceBundle rb) {
  76. // TODO
  77. }
  78.  
  79. @FXML
  80. private void clickSubmit(ActionEvent event) {
  81.  
  82. if (event.getSource()==submit) {
  83. if (password.equals(password2)) {
  84.  
  85. lbl.setText("Done....Thank You!");
  86.  
  87. }
  88. else
  89. {
  90.  
  91. lbl.setText("Two password aren't same");
  92. }
  93.  
  94.  
  95. }
  96. }
  97.  
  98.  
  99. }
  100.  
  101.  
  102.  
  103.  
  104.  
  105. //java Fx..............................................................................
  106.  
  107. <?xml version="1.0" encoding="UTF-8"?>
  108.  
  109. <?import javafx.geometry.Insets?>
  110. <?import javafx.scene.control.Button?>
  111. <?import javafx.scene.control.Label?>
  112. <?import javafx.scene.control.PasswordField?>
  113. <?import javafx.scene.control.TextArea?>
  114. <?import javafx.scene.layout.HBox?>
  115. <?import javafx.scene.layout.VBox?>
  116. <?import javafx.scene.text.Font?>
  117.  
  118. <VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafxdemo.FXMLController">
  119. <children>
  120. <Label prefHeight="58.0" prefWidth="90.0" text="Sign Up">
  121. <font>
  122. <Font name="System Bold" size="12.0" />
  123. </font></Label>
  124. <HBox prefHeight="43.0" prefWidth="600.0">
  125. <children>
  126. <Label prefHeight="43.0" prefWidth="101.0" text="Email:" />
  127. <TextArea fx:id="email" prefHeight="43.0" prefWidth="188.0" />
  128. </children>
  129. </HBox>
  130. <HBox prefHeight="43.0" prefWidth="600.0">
  131. <children>
  132. <Label prefHeight="43.0" prefWidth="102.0" text="User Name :" />
  133. <TextArea fx:id="username" prefHeight="43.0" prefWidth="188.0" />
  134. </children>
  135. </HBox>
  136. <HBox prefHeight="43.0" prefWidth="600.0">
  137. <children>
  138. <Label prefHeight="43.0" prefWidth="100.0" text="Password:" />
  139. <PasswordField fx:id="password" prefHeight="43.0" prefWidth="190.0" />
  140. </children>
  141. </HBox>
  142. <HBox prefHeight="43.0" prefWidth="600.0">
  143. <children>
  144. <Label prefHeight="43.0" prefWidth="99.0" text="Confirm Password" />
  145. <PasswordField fx:id="password2" prefHeight="43.0" prefWidth="190.0" />
  146. </children>
  147. </HBox>
  148. <Label fx:id="lbl" prefHeight="17.0" prefWidth="314.0" />
  149. <Button fx:id="submit" mnemonicParsing="false" onAction="#clickSubmit" prefHeight="25.0" prefWidth="61.0" text="Submit">
  150. <VBox.margin>
  151. <Insets />
  152. </VBox.margin>
  153. </Button>
  154. </children>
  155. </VBox>
  156.  
Add Comment
Please, Sign In to add comment