本文整理匯總了Java中javafx.scene.control.ScrollPane.setPrefHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollPane.setPrefHeight方法的具體用法?Java ScrollPane.setPrefHeight怎麽用?Java ScrollPane.setPrefHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.ScrollPane
的用法示例。
在下文中一共展示了ScrollPane.setPrefHeight方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: homeProducts
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
public static BorderPane homeProducts(){
VBox products = new VBox(20);
products.getChildren().addAll(
fetchProducts.productbyType("Discounts for You"),
fetchProducts.productbyType("Featured Product"),
fetchProducts.productbyType("New Arrival"),
fetchProducts.productbyType("Trending"));
ScrollPane proScroller = new ScrollPane(products);
proScroller.setPrefHeight(400);
proScroller.setFitToWidth(true);
BorderPane home = new BorderPane(proScroller);
return home;
}
示例2: init
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setScene(new Scene(root));
VBox vRoot = new VBox();
vRoot.setPadding(new Insets(8, 8, 8, 8));
vRoot.setSpacing(5);
htmlEditor = new HTMLEditor();
htmlEditor.setPrefSize(500, 245);
htmlEditor.setHtmlText(INITIAL_TEXT);
vRoot.getChildren().add(htmlEditor);
final Label htmlLabel = new Label();
htmlLabel.setMaxWidth(500);
htmlLabel.setWrapText(true);
ScrollPane scrollPane = new ScrollPane();
scrollPane.getStyleClass().add("noborder-scroll-pane");
scrollPane.setContent(htmlLabel);
scrollPane.setFitToWidth(true);
scrollPane.setPrefHeight(180);
Button showHTMLButton = new Button("Show the HTML below");
vRoot.setAlignment(Pos.CENTER);
showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
htmlLabel.setText(htmlEditor.getHtmlText());
}
});
vRoot.getChildren().addAll(showHTMLButton, scrollPane);
root.getChildren().addAll(vRoot);
}
示例3: start
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml"));
AnchorPane page = loader.load();
UiController uiController = loader.getController();
uiController.setStageAndSetupListeners(primaryStage);
ScrollPane toolPane = (ScrollPane) page.lookup("#mToolPane");
toolPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
double width = toolPane.getPrefWidth();
double height = toolPane.getPrefHeight();
MenuBar menuBar = (MenuBar) page.lookup("#mMenuBar");
menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
double menuHeight = 25;
toolPane.setPrefHeight(1000 > height ? 1000:height);
Scene scene = new Scene(page, width + 1000, 1000 > height ? 1000 + menuHeight : height + menuHeight);
primaryStage.setScene(scene);
primaryStage.setTitle(TITLE);
primaryStage.show();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
Platform.exit();
System.exit(0);
}
});
} catch (IOException ioe) {
Logger.getLogger(TAG).log(Level.SEVERE, null, ioe);
}
}
示例4: HTMLEditorSample
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
public HTMLEditorSample() {
VBox vRoot = new VBox();
vRoot.setPadding(new Insets(8, 8, 8, 8));
vRoot.setSpacing(5);
htmlEditor = new HTMLEditor();
htmlEditor.setPrefSize(500, 245);
htmlEditor.setHtmlText(INITIAL_TEXT);
vRoot.getChildren().add(htmlEditor);
final Label htmlLabel = new Label();
htmlLabel.setMaxWidth(500);
htmlLabel.setWrapText(true);
ScrollPane scrollPane = new ScrollPane();
scrollPane.getStyleClass().add("noborder-scroll-pane");
scrollPane.setContent(htmlLabel);
scrollPane.setFitToWidth(true);
scrollPane.setPrefHeight(180);
Button showHTMLButton = new Button("Show the HTML below");
vRoot.setAlignment(Pos.CENTER);
showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
htmlLabel.setText(htmlEditor.getHtmlText());
}
});
vRoot.getChildren().addAll(showHTMLButton, scrollPane);
getChildren().addAll(vRoot);
// REMOVE ME
// Workaround for RT-16781 - HTML editor in full screen has wrong border
javafx.scene.layout.GridPane grid = (javafx.scene.layout.GridPane)htmlEditor.lookup(".html-editor");
for(javafx.scene.Node child: grid.getChildren()) {
javafx.scene.layout.GridPane.setHgrow(child, javafx.scene.layout.Priority.ALWAYS);
}
// END REMOVE ME
}
示例5: start
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
@Override
public void start(Stage stage) {
stage.setTitle("HTMLEditor Sample");
stage.setWidth(500);
stage.setHeight(500);
Scene scene = new Scene(new Group());
VBox root = new VBox();
root.setPadding(new Insets(8, 8, 8, 8));
root.setSpacing(5);
root.setAlignment(Pos.BOTTOM_LEFT);
final HTMLEditor htmlEditor = new HTMLEditor();
htmlEditor.setPrefHeight(245);
htmlEditor.setHtmlText(INITIAL_TEXT);
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
ScrollPane scrollPane = new ScrollPane();
scrollPane.getStyleClass().add("noborder-scroll-pane");
scrollPane.setStyle("-fx-background-color: white");
scrollPane.setContent(browser);
scrollPane.setFitToWidth(true);
scrollPane.setPrefHeight(180);
Button showHTMLButton = new Button("Load Content in Browser");
root.setAlignment(Pos.CENTER);
showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
webEngine.loadContent(htmlEditor.getHtmlText());
}
});
root.getChildren().addAll(htmlEditor, showHTMLButton, scrollPane);
scene.setRoot(root);
stage.setScene(scene);
stage.show();
}