本文整理匯總了Java中javafx.scene.control.ScrollPane.setPrefSize方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollPane.setPrefSize方法的具體用法?Java ScrollPane.setPrefSize怎麽用?Java ScrollPane.setPrefSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.ScrollPane
的用法示例。
在下文中一共展示了ScrollPane.setPrefSize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addPropertiesTable
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
public void addPropertiesTable(String domainName, Node content) {
try {
final Tab newTab = new Tab(domainName);
final ScrollPane sp = new ScrollPane();
sp.setPannable(true);
sp.setContent(content);
sp.setPrefSize(content.getBoundsInLocal().getWidth(), content.getBoundsInLocal().getHeight());
sp.setMaxSize(1000, 1000);
content.boundsInLocalProperty().addListener(new ChangeListener<Bounds>() {
public void changed(ObservableValue<? extends Bounds> ov, Bounds t, Bounds t1) {
sp.setPrefSize(t1.getWidth(), t1.getHeight());
}
});
content.setId(domainName.toUpperCase() + PropertiesTable.PROPERTIES_TABLE_SUFFIX_ID);
newTab.setContent(sp);
sp.setId(domainName + TAB_CONTENT_ID);
this.getTabs().add(newTab);
} catch (Throwable ex) {
log(ex);
}
}
示例2: start
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
@Override
public void start(Stage stage) {
Node content = new Rectangle(1000, 700, Color.GREEN);
ScrollPane scrollPane = new ScrollPane(content);
scrollPane.setPrefSize(500, 300);
ChangeListener<Object> changeListener = new ChangeListener<Object>() {
@Override
public void changed(ObservableValue<? extends Object> observable, Object oldValue, Object newValue) {
double hmin = scrollPane.getHmin();
double hmax = scrollPane.getHmax();
double hvalue = scrollPane.getHvalue();
double contentWidth = content.getLayoutBounds().getWidth();
double viewportWidth = scrollPane.getViewportBounds().getWidth();
double hoffset =
Math.max(0, contentWidth - viewportWidth) * (hvalue - hmin) / (hmax - hmin);
double vmin = scrollPane.getVmin();
double vmax = scrollPane.getVmax();
double vvalue = scrollPane.getVvalue();
double contentHeight = content.getLayoutBounds().getHeight();
double viewportHeight = scrollPane.getViewportBounds().getHeight();
double voffset =
Math.max(0, contentHeight - viewportHeight) * (vvalue - vmin) / (vmax - vmin);
System.out.printf("Offset: [%.1f, %.1f] width: %.1f height: %.1f %n",
hoffset, voffset, viewportWidth, viewportHeight);
}
};
scrollPane.viewportBoundsProperty().addListener(changeListener);
scrollPane.hvalueProperty().addListener(changeListener);
scrollPane.vvalueProperty().addListener(changeListener);
Scene scene = new Scene(scrollPane, 640, 480);
stage.setScene(scene);
stage.show();
}
示例3: TaskViewer
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
public TaskViewer() {
super(370, 235, 0, 0, "Task Manager");
getStylesheets().add("css/taskViewer.css");
this.getStyleClass().add("task-viewer");
macrosDropdown = macroDropdownSetup();
ScrollPane scroll = new ScrollPane();
scroll.getStyleClass().add("scroll");
scroll.setPrefSize(235, 300);
scroll.setVbarPolicy(ScrollBarPolicy.ALWAYS);
taskViewerBox = new VBox(8);
taskViewerBox.getStyleClass().add("task-viewer-inner");
taskPanes = new ArrayList<TaskPane>();
scroll.setContent(taskViewerBox);
BorderPane taskViewerRootPane = new BorderPane();
taskViewerRootPane.setCenter(scroll);
HBox buttonSection = new HBox(5);
buttonSection.setPrefSize(235, 30);
buttonSection.getStyleClass().add("button-section");
buttonSection.setPadding(new Insets(2));
buttonSection.setAlignment(Pos.CENTER);
addDeleteButton(buttonSection);
addMoveButtons(buttonSection);
addMacroButtons(buttonSection);
Platform.runLater(() -> {
Tooltip.install(macrosDropdown, new Tooltip("Macros"));
});
buttonSection.getChildren().add(macrosDropdown);
taskViewerRootPane.setBottom(buttonSection);
this.setContent(taskViewerRootPane);
}
示例4: drawTo
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
@Override
void drawTo(Pane paneTo) {
TilePane tilePane = new TilePane();
tilePane.setHgap(HGAP);
tilePane.setVgap(VGAP);
if (0 == getActionHolderList().size()) {
return;
} else {
for (ActionHolder ah : getActionHolderList()) {
Collection<? extends Node> childnodes = ah.draw();
if (null != childnodes && 0 != childnodes.size()) {
createSlot(((TestNode) ah).getName(), childnodes, tilePane);
} else {
// TODO
}
}
}
ScrollPane scrollPane = new ScrollPane();
scrollPane.setPrefSize(getWidth(), getHeight());
scrollPane.setMaxSize(getWidth(), getHeight());
scrollPane.setContent(tilePane);
scrollPane.setStyle("-fx-padding: 10;-fx-background: white;-fx-border-color: gray;");
paneTo.getChildren().add(scrollPane);
}
示例5: start
import javafx.scene.control.ScrollPane; //導入方法依賴的package包/類
@Override
public void start(Stage stage) {
// Node content = new Rectangle(1000, 700, Color.GREEN);
Pane pane = new Pane();
pane.setPrefSize(TEN_BILLIONS, TEN_BILLIONS);
ScrollPane scrollPane = new ScrollPane(pane);
scrollPane.setPrefSize(500, 300);
ChangeListener<Object> changeListener = new ChangeListener<Object>() {
@Override
public void changed(ObservableValue<? extends Object> observable, Object oldValue, Object newValue) {
System.out.println("source=" + observable.toString());
double hmin = scrollPane.getHmin();
double hmax = scrollPane.getHmax();
double hvalue = scrollPane.getHvalue();
double contentWidth = pane.getLayoutBounds().getWidth();
double viewportWidth = scrollPane.getViewportBounds().getWidth();
double hoffset =
Math.max(0, contentWidth - viewportWidth) * (hvalue - hmin) / (hmax - hmin);
double vmin = scrollPane.getVmin();
double vmax = scrollPane.getVmax();
double vvalue = scrollPane.getVvalue();
double contentHeight = pane.getLayoutBounds().getHeight();
double viewportHeight = scrollPane.getViewportBounds().getHeight();
double voffset =
Math.max(0, contentHeight - viewportHeight) * (vvalue - vmin) / (vmax - vmin);
System.out.printf("Offset: [%.1f, %.1f] width: %.1f height: %.1f %n",
hoffset, voffset, viewportWidth, viewportHeight);
}
};
scrollPane.viewportBoundsProperty().addListener(changeListener);
scrollPane.hvalueProperty().addListener(changeListener);
scrollPane.vvalueProperty().addListener(changeListener);
/* Drawing on the region */
Canvas canvas1 = new Canvas(100, 100);
canvas1.relocate(TEN_BILLIONS - 100, 0);
canvas1.getGraphicsContext2D().strokeOval(60, 60, 30, 30);
Canvas canvas2 = new Canvas(100, 100);
canvas2.relocate(TEN_BILLIONS - 100, TEN_BILLIONS - 100);
canvas2.getGraphicsContext2D().fillOval(60, 60, 30, 30);
pane.getChildren().addAll(canvas1, canvas2);
/* Showing the scene */
Scene scene = new Scene(scrollPane, 640, 480);
stage.setScene(scene);
stage.show();
}