内容不适合ScrollPane。无法滚动直到结束

时间:2018-05-20 18:23:57

标签: java javafx

我试图让我的内容适合我的scrollPane。但是,直到内容结束我才能滚动。它可以工作,如果将整个窗格调整到我的电脑屏幕(1920,1080),但它不适合我的笔记本电脑分辨率(1366,768)。 这就是发生的事情

///////////////////////////////////////////////////CENTER SIDE OF THE PANE///////////////////////////////////////////////////
//Scroll Pane for insert centerbox in it
ScrollPane scroll = new ScrollPane();


//Grid pane for center box
GridPane centerbox= new GridPane();
centerbox.setHgap(15);
centerbox.setVgap(30);




//Input picture
javafx.scene.image.Image img = new     
javafx.scene.image.Image(getClass().getResource("arcade.jpg").toExternalForm());
ImageView imgv1 = new ImageView(img);
imgv1.setFitHeight(150);
imgv1.setFitWidth(150);
imgv1.setVisible(true);

Image img2 = new Image(getClass().getResource("Bowling.jpg").toExternalForm());
ImageView imgv2 = new ImageView(img2);
imgv2.setFitHeight(150);
imgv2.setFitWidth(150);
imgv2.setVisible(true);

Image img3 = new Image(getClass().getResource("cc.jpg").toExternalForm());
ImageView imgv3 = new ImageView(img3);
imgv3.setFitHeight(150);
imgv3.setFitWidth(150);
imgv3.setVisible(true);

Image img4 = new Image(getClass().getResource("circus.jpg").toExternalForm());
ImageView imgv4 = new ImageView(img4);
imgv4.setFitHeight(150);
imgv4.setFitWidth(150);
imgv4.setVisible(true);

Image img5= new Image(getClass().getResource("karaoke.jpg").toExternalForm());
ImageView imgv5 = new ImageView(img5);
imgv5.setFitHeight(150);
imgv5.setFitWidth(150);
imgv5.setVisible(true);

Image img6= new Image(getClass().getResource("kidzania.jpg").toExternalForm());
ImageView imgv6 = new ImageView(img6);
imgv6.setFitHeight(150);
imgv6.setFitWidth(150);
imgv6.setVisible(true);

Image img7= new Image(getClass().getResource("skatepark.jpg").toExternalForm());
ImageView imgv7 = new ImageView(img7);
imgv7.setFitHeight(150);
imgv7.setFitWidth(150);
imgv7.setVisible(true);






//////////////////////////////////////////////COMBINING ALL THE PANE TOGETHER////////////////////////////////////////////////////////


//Place Node on Pane(1)
centerbox.add(imgv1,0,0);
Button buy = new Button("Reserve");
Label l1 = new Label();
l1.setText("'Arcade-ium'\n\n\nAt Arcade-ium, you can enjoy a lot of classic and modern arcade game.\nWe assure you your satisfaction");
l1.setFont(Font.font("Helvetica",FontWeight.BOLD,20));
centerbox.add(buy,2,0);
centerbox.add(l1,1,0);


//Event Handler to change scene to reservepage
buy.setOnAction(e->{
    Stage stg = (Stage)buy.getScene().getWindow();
    stg.setScene(rp.getScene1());
});




 ///Repeat until 7 node
//Place Node on Pane(7)
centerbox.add(imgv7,0,6);
Button buy6 = new Button("Reserve");
Label l7 = new Label();
l7.setText("'xTremePark'\n\nxTremePark was built in 2011. We have a lot of facilities here to facilitate our youngster who\nlove to take the risk and go beyond.");
l7.setFont((Font.font("helvetica",FontWeight.BOLD,20)));
centerbox.add(l7,1,6);
centerbox.add(buy6,2,6);

//Event Handler to change scene to reservepage
buy6.setOnAction(e->{
    Stage stg = (Stage)buy6.getScene().getWindow();
    stg.setScene(rp.getScene7());
});


//Formatting the pane
scroll.setContent(centerbox);

//Im using borderpane for the whole scene. And Im going to insert the scrollpane into the center. 

当我运行程序时,我似乎无法滚动直到结束我的内容。我尝试使用.setMinHeight()和.setPrefHeight()。

但是没有工作。那么有什么方法可以设置滚动条在我的滚动条中滚动多少? Image 1

0 个答案:

没有答案