Advertisement
Guest User

Untitled

a guest
May 15th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package starting;
  7.  
  8. import java.awt.Color;
  9. import javafx.application.Application;
  10. import javafx.event.ActionEvent;
  11. import javafx.event.EventHandler;
  12. import javafx.geometry.Pos;
  13. import javafx.scene.Scene;
  14. import javafx.scene.control.Button;
  15. import javafx.scene.control.Label;
  16. import javafx.scene.control.PasswordField;
  17. import javafx.scene.control.TextField;
  18. import javafx.scene.image.Image;
  19. import javafx.scene.image.ImageView;
  20. import javafx.scene.layout.BackgroundImage;
  21. import javafx.scene.layout.GridPane;
  22. import javafx.scene.layout.HBox;
  23. import javafx.scene.layout.StackPane;
  24. import javafx.scene.layout.VBox;
  25. import javafx.stage.Stage;
  26.  
  27. /**
  28. *
  29. * @author Susmi
  30. */
  31. public class Starting extends Application {
  32.  
  33. @Override
  34. public void start(Stage primaryStage) {
  35. Button btn = new Button();
  36. Button exit = new Button();
  37. btn.setText("Game");
  38. exit.setText("Exit");
  39.  
  40. exit.setOnAction(e->{
  41. System.exit(0);
  42. });
  43. Label label1 =new Label("WELCOME");
  44. //for the first scene
  45. VBox root = new VBox();
  46. //StackPane root=new StackPane();
  47. Image image=new Image("newstart.jpg");
  48. ImageView i=new ImageView(image);
  49. root.getChildren().add(i);
  50. //VBox root=new VBox();
  51. root.setAlignment(Pos.CENTER);
  52. root.getChildren().addAll(label1,btn, exit);
  53. //root.getChildren().add(btn);
  54.  
  55. //StackPane root1=new StackPane();
  56.  
  57.  
  58.  
  59. //Scene scene1 = new Scene(root, 500, 281);
  60.  
  61. Scene scene1 = new Scene(root, 1200, 700);
  62.  
  63.  
  64. //2nd page button
  65. Button btn1 = new Button();
  66. btn1.setText("Back");
  67. btn1.setOnAction(e-> {
  68.  
  69. primaryStage.setScene(scene1);
  70. });
  71. //2nd scene layout
  72. StackPane root1=new StackPane();
  73. //Button btn1=new Button("Login");
  74. //GridPane root1=new GridPane();
  75. Image image1=new Image("newstart.jpg");
  76. ImageView i1=new ImageView(image1);
  77.  
  78. root1.getChildren().add(i1);
  79. root1.setAlignment(Pos.CENTER);
  80. /*root1.setVgap(10);
  81. root1.setHgap(10);
  82. Label username=new Label("Username");
  83. Label password=new Label("Password");
  84.  
  85. root1.add(username,0,0);
  86. root1.add(password,0,1);
  87.  
  88. TextField user=new TextField();
  89. PasswordField pass=new PasswordField();
  90.  
  91. root1.add(user, 1, 0);
  92. root1.add(pass, 1, 1);
  93.  
  94.  
  95.  
  96. HBox hbox=new HBox();
  97. hbox.getChildren().add(btn1);
  98. hbox.setAlignment(Pos.CENTER_RIGHT);
  99.  
  100.  
  101. //root1.add(hbox, 1, 2);*/
  102. root1.getChildren().add(btn1);
  103. Scene scene2 = new Scene(root1, 1200, 700);
  104. btn.setOnAction(e-> {
  105.  
  106. primaryStage.setScene(scene2);
  107. });
  108.  
  109.  
  110. primaryStage.setTitle("Hello World!");
  111. primaryStage.setScene(scene1);
  112. primaryStage.show();
  113. }
  114.  
  115. /**
  116. * @param args the command line arguments
  117. */
  118. public static void main(String[] args) {
  119. launch(args);
  120. }
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement