Advertisement
Guest User

java code

a guest
Jan 23rd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1.  
  2. import javafx.application.Application;
  3. import javafx.event.ActionEvent;
  4. import javafx.event.EventHandler;
  5. import javafx.scene.Scene;
  6. import javafx.scene.control.Button;
  7. import javafx.scene.control.Label;
  8. import javafx.scene.image.Image;
  9. import javafx.scene.layout.HBox;
  10. import javafx.stage.Stage;
  11.  
  12. public class Main extends Application {
  13.  
  14. Button nPg2, nPg3, nPg4, nPg5, nPg6;
  15. Stage stage;
  16. Scene scene1, scene2, scene3, scene4, scene5, scene6;
  17. Button lPg1, lPg2, lPg3, lPg4, lPg5;
  18. int pageNum = 1;
  19.  
  20. public static void main(String[] args) {
  21. // setup javafx
  22. launch(args);
  23. }
  24.  
  25. @Override
  26. public void start(Stage stage) throws Exception{
  27. Label body1 = new Label("first page");
  28. Label body2 = new Label("second page");
  29. Label body3 = new Label("third page");
  30. Label body4 = new Label("last page");
  31. Image img1, img2, img3, img4, img5;
  32. nPg2 = new Button("NextPage2");
  33. nPg3 = new Button("NextPage3");
  34. nPg4 = new Button("NextPage4");
  35. nPg5 = new Button("NextPage5");
  36. //sets the text of the buttons and the labels, and declares all the images
  37. nPg2.setOnAction(new EventHandler<ActionEvent>(){
  38. @Override
  39. public void handle(ActionEvent event) {
  40. stage.setScene(scene2);
  41. }
  42. } );
  43. //makes next page 2 go to page 2
  44. HBox layout1 = new HBox(5);
  45. //makes a new layout with 5 px seperation
  46. layout1.getChildren().addAll(body1, nPg2);
  47. //adds both of the buttons and body1 to the layout
  48. scene1 = new Scene(layout1, 300, 250);
  49. //makes scene1 from layout1 and dimensions
  50. HBox layout2 = new HBox(5);
  51. //makes layout2
  52. layout2.getChildren().addAll(lPg1, body2, nPg3);
  53. scene2 = new Scene(layout2, 300, 250);
  54. stage.setScene(scene1);
  55. stage.setTitle("title");
  56. stage.show();
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement