2013-06-05 134 views

回答

0

stage.setScene(new ScrollPane(yourContent));應該這樣做。 當然您的內容應該具有合適的最小值,最大值和優選的尺寸

2

如果所述ScrollPane的含量低於ScrollPane允許的大小時,應當ScrollPane自動附加滾動條。下面是一個例子:

public class JFXScroll extends Application { 

    @Override 
    public void start(Stage stage) throws Exception { 

     BorderPane main = new BorderPane(); 

     ScrollPane scroll = new ScrollPane(); 
     VBox box = new VBox(); 

     // Demo purposes; Wouldn't normally do this - just let the box automatically fit the content 
     box.setPrefSize(1000, 500); 
     box.setEffect(new ColorInput(0,0,1000,500,Color.LIME)); 

     scroll.setContent(box); 

     main.setLeft(new Label("Left Content")); 
     main.setCenter(scroll); 

     Scene scene = new Scene(main, 300, 250); 
     stage.setScene(scene); 
     stage.show(); 


    } 
    public static void main(String[] args) { 
     launch(args); 
    } 
}