Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.image.Image;
- import javafx.scene.layout.HBox;
- import javafx.stage.Stage;
- public class Main extends Application {
- Button nPg2, nPg3, nPg4, nPg5, nPg6;
- Stage stage;
- Scene scene1, scene2, scene3, scene4, scene5, scene6;
- Button lPg1, lPg2, lPg3, lPg4, lPg5;
- int pageNum = 1;
- public static void main(String[] args) {
- // setup javafx
- launch(args);
- }
- @Override
- public void start(Stage stage) throws Exception{
- Label body1 = new Label("first page");
- Label body2 = new Label("second page");
- Label body3 = new Label("third page");
- Label body4 = new Label("last page");
- Image img1, img2, img3, img4, img5;
- nPg2 = new Button("NextPage2");
- nPg3 = new Button("NextPage3");
- nPg4 = new Button("NextPage4");
- nPg5 = new Button("NextPage5");
- //sets the text of the buttons and the labels, and declares all the images
- nPg2.setOnAction(new EventHandler<ActionEvent>(){
- @Override
- public void handle(ActionEvent event) {
- stage.setScene(scene2);
- }
- } );
- //makes next page 2 go to page 2
- HBox layout1 = new HBox(5);
- //makes a new layout with 5 px seperation
- layout1.getChildren().addAll(body1, nPg2);
- //adds both of the buttons and body1 to the layout
- scene1 = new Scene(layout1, 300, 250);
- //makes scene1 from layout1 and dimensions
- HBox layout2 = new HBox(5);
- //makes layout2
- layout2.getChildren().addAll(lPg1, body2, nPg3);
- scene2 = new Scene(layout2, 300, 250);
- stage.setScene(scene1);
- stage.setTitle("title");
- stage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement