本文整理汇总了Java中javafx.scene.control.ScrollPane类的典型用法代码示例。如果您正苦于以下问题:Java ScrollPane类的具体用法?Java ScrollPane怎么用?Java ScrollPane使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScrollPane类属于javafx.scene.control包,在下文中一共展示了ScrollPane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
public void start(Stage primaryStage, ScrollPane rootLayout) throws Exception {
primaryStage.setTitle("Change Hotkeys");
Scene myScene = new Scene(rootLayout);
ourStage = primaryStage;
myScene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
public void handle(KeyEvent event) {
if (changeHotkey) {
if (addHotkey(event, changeHotkeyFunction)) {
changeHotkey = false;
}
}
}
});
Label divider = new Label();
HBox labelHbox = new HBox(divider);
divider.setText("----These hotkeys are not changeable----");
labelHbox.setAlignment(Pos.CENTER);
for (String key : HOTKEYS) {
hotkeyVBox.getChildren().add(hotkeys.get(key).getHotkeyHBox());
}
hotkeyVBox.getChildren().add(labelHbox);
for (ImmutableHotkey hotkey : IMMUTABLE_HOTKEYS) {
hotkeyVBox.getChildren().add(hotkey.getHotkeyHBox());
}
primaryStage.setScene(myScene);
}
示例2: createTextArea
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
private Node createTextArea(boolean selectable, boolean editable) {
textArea = new TextArea();
textArea.setPrefRowCount(4);
textArea.setEditable(editable);
textArea.textProperty().addListener((observable, oldValue, newValue) -> {
text = textArea.getText();
});
textArea.setText(text);
ScrollPane scrollPane = new ScrollPane(textArea);
scrollPane.setFitToWidth(true);
scrollPane.setFitToHeight(true);
scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS);
HBox.setHgrow(scrollPane, Priority.ALWAYS);
return scrollPane;
}
示例3: ensureVisible
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
void ensureVisible(double x, double y) {
ScrollPane scrollPane = diagramController.getScrollPane();
double xScroll = (x - scrollPane.getWidth() / 2) / (8000 - scrollPane.getWidth());
double yScroll = (y - scrollPane.getHeight() / 2) / (8000 - scrollPane.getHeight());
final Timeline timeline = new Timeline();
final KeyValue kv1 = new KeyValue(scrollPane.hvalueProperty(), xScroll);
final KeyValue kv2 = new KeyValue(scrollPane.vvalueProperty(), yScroll);
final KeyFrame kf = new KeyFrame(Duration.millis(100), kv1, kv2);
timeline.getKeyFrames().add(kf);
timeline.play();
aScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
aScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
}
示例4: FlowCardComposite
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
/**
* @param nodeConverter
*/
public FlowCardComposite() {
scrollPane = new ScrollPane();
scrollPane.setFitToHeight(true);
scrollPane.setFitToWidth(true);
scrollPane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
StackPane stackPane = new StackPane(scrollPane);
stackPane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
masonryPane = new JFXMasonryPane();
scrollPane.setContent(masonryPane);
setCenter(stackPane);
initialize();
masonryPane.setCache(false);
setStyle("-fx-background-color : #292929");
}
示例5: listCreatureContents
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
private void listCreatureContents(Player current, ScrollPane scroll) {
HBox content = new HBox();
scroll.setContent(content);
content.setSpacing(20);
for (Card c : current.getPlayerCreature()) {
Rectangle rectangle = new Rectangle(100, 120);
Image img = new Image("images/Spellmonger_" + c.getName() + ".png");
rectangle.setFill(new ImagePattern(img));
rectangle.setLayoutY(10);
rectangle.getStyleClass().add("cartes_ombre");
content.getChildren().add(rectangle);
if (!player1.isDead() && !player2.isDead()) {
Rectangle newRectangle = new Rectangle(250, 300);
eventEnter(rectangle, newRectangle, img);
eventExit(rectangle, newRectangle);
}
}
}
示例6: autofit
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
void autofit() {
Platform.runLater( new Runnable() {
@Override
public void run() {
if( container.getScene().getRoot() instanceof ScrollPane ) {
BorderPane pane = new BorderPane();
pane.setCenter( browser );
container.getScene().setRoot( pane );
}
preferredWidth = -1;
preferredHeight = -1;
browser.setMaxWidth( Integer.MAX_VALUE );
browser.setMaxHeight( Integer.MAX_VALUE );
browser.setMinWidth( -1 );
browser.setMinHeight( -1 );
browser.autosize();
}
});
}
示例7: ensureVisible
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
private static void ensureVisible(ScrollPane pane, Node node) {
Bounds viewport = pane.getViewportBounds();
double contentHeight = pane.getContent().getBoundsInLocal().getHeight();
double contentWidth = pane.getContent().getBoundsInLocal().getWidth();
double nodeMinY = node.getBoundsInParent().getMinY();
double nodeMaxY = node.getBoundsInParent().getMaxY();
double nodeMinX = node.getBoundsInParent().getMinX();
double nodeMaxX = node.getBoundsInParent().getMaxX();
double viewportMinY = (contentHeight - viewport.getHeight()) * pane.getVvalue();
double viewportMaxY = viewportMinY + viewport.getHeight();
double viewportMinX = (contentWidth - viewport.getWidth()) * pane.getHvalue();
double viewportMaxX = viewportMinX + viewport.getWidth();
if (nodeMinY < viewportMinY) {
pane.setVvalue(nodeMinY / (contentHeight - viewport.getHeight()));
} else if (nodeMaxY > viewportMaxY) {
pane.setVvalue((nodeMaxY - viewport.getHeight()) / (contentHeight - viewport.getHeight()));
}
if (nodeMinX < viewportMinX) {
pane.setHvalue(nodeMinX / (contentWidth - viewport.getWidth()));
} else if (nodeMaxX > viewportMaxX) {
pane.setHvalue((nodeMaxX - viewport.getWidth()) / (contentWidth - viewport.getWidth()));
}
}
示例8: initComponents
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
private void initComponents(boolean selectable) {
initVerticalButtonBar();
pane = new ScrollPane();
HBox.setHgrow(pane, Priority.ALWAYS);
setCenter(pane);
if (selectable) {
setRight(verticalButtonBar);
verticalButtonBar.setStyle("-fx-padding: 5px");
verticalButtonBar.setDisable(true);
}
VBox titleBox = new VBox();
Label titleLabel = new Label("Editing CheckList", FXUIUtils.getIcon("newCheckList"));
titleLabel.getStyleClass().add("modaldialog-title");
titleBox.getChildren().add(titleLabel);
titleBox.getChildren().add(new Separator());
setTop(titleBox);
}
示例9: initCheckList
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
private void initCheckList() {
ToolBar toolBar = new ToolBar();
toolBar.getItems().add(new Text("Check Lists"));
toolBar.setMinWidth(Region.USE_PREF_SIZE);
leftPane.setTop(toolBar);
checkListElements = checkListInfo.getCheckListElements();
checkListView = new ListView<CheckListForm.CheckListElement>(checkListElements);
checkListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
CheckListElement selectedItem = checkListView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
doneButton.setDisable(true);
return;
}
Node checkListForm = getChecklistFormNode(selectedItem, Mode.DISPLAY);
if (checkListForm == null) {
doneButton.setDisable(true);
return;
}
doneButton.setDisable(false);
ScrollPane sp = new ScrollPane(checkListForm);
sp.setFitToWidth(true);
sp.setPadding(new Insets(0, 0, 0, 10));
rightPane.setCenter(sp);
});
leftPane.setCenter(checkListView);
}
示例10: ensureVisible
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
protected void ensureVisible(Node target) {
ScrollPane scrollPane = getParentScrollPane(target);
if (scrollPane == null) {
return;
}
Node content = scrollPane.getContent();
Bounds contentBounds = content.localToScene(content.getBoundsInLocal());
Bounds viewportBounds = scrollPane.getViewportBounds();
Bounds nodeBounds = target.localToScene(target.getBoundsInLocal());
if (scrollPane.contains(nodeBounds.getMinX() - contentBounds.getMinX(), nodeBounds.getMinY() - contentBounds.getMinY())) {
return;
}
double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY())
* ((scrollPane.getVmax() - scrollPane.getVmin()) / (contentBounds.getHeight() - viewportBounds.getHeight()));
scrollPane.setVvalue(toVScroll);
double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX())
* ((scrollPane.getHmax() - scrollPane.getHmin()) / (contentBounds.getWidth() - viewportBounds.getWidth()));
scrollPane.setHvalue(toHScroll);
}
示例11: scrollTo
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
private void scrollTo(Node target) {
ScrollPane scrollPane = getParentScrollPane(target);
if (scrollPane == null)
return;
Node content = scrollPane.getContent();
Bounds contentBounds = content.localToScene(content.getBoundsInLocal());
Bounds viewportBounds = scrollPane.getViewportBounds();
Bounds nodeBounds = target.localToScene(target.getBoundsInLocal());
double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY())
* ((scrollPane.getVmax() - scrollPane.getVmin())
/ (contentBounds.getHeight() - viewportBounds.getHeight()));
if (toVScroll >= scrollPane.getVmin() && toVScroll < scrollPane.getVmax())
scrollPane.setVvalue(toVScroll);
double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX())
* ((scrollPane.getHmax() - scrollPane.getHmin())
/ (contentBounds.getWidth() - viewportBounds.getWidth()));
if (toHScroll >= scrollPane.getHmin() && toHScroll < scrollPane.getHmax())
scrollPane.setHvalue(toHScroll);
}
示例12: SettingsViewSkin
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
public SettingsViewSkin(SettingsView control) {
super(control);
VBox container = new VBox();
container.getStyleClass().add("container");
ScrollPane scrollPane = new ScrollPane(control.getSourceView());
scrollPane.setPrefViewportHeight(180);
container.getChildren().addAll(
new SectionTitle("Paper"),
control.getPaperView(),
new SectionTitle("Time Range"),
control.getTimeRangeView(),
new SectionTitle("Calendars"),
scrollPane,
new SectionTitle("Options"),
control.getOptionsView());
getChildren().add(container);
}
示例13: 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;
}
示例14: setup
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
private void setup(Stage primaryStage) {
Pane root = (Pane) FXML.load(getClass(), "/assets/scenes/MainScene.fxml");
root.setPrefSize(preferences.getInt("resolution.width"), preferences.getInt("resolution.height"));
Scene scene = new Scene(root, preferences.getInt("resolution.width"), preferences.getInt("resolution.height"));
CSS.load(getClass(), scene, "/assets/stylesheets/styles.css");
ScrollPane scrollPane = new ScrollPane();
scrollPane.setId("scrollpane");
root.getChildren().add(scrollPane);
initBoxes(root, scene);
SimpleStage stage = new SimpleStage(primaryStage);
stage.setIcon(getClass(), "/assets/icon.png");
stage.show(scene, "JRFL v" + VERSION, preferences.getBoolean("resizable"));
}
示例15: buildUI
import javafx.scene.control.ScrollPane; //导入依赖的package包/类
private void buildUI() {
contentWrapper = new ScrollPane();
contentWrapper.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
getChildren().add(contentWrapper);
setTopAnchor(contentWrapper, 0d);
setLeftAnchor(contentWrapper, 0d);
setBottomAnchor(contentWrapper, 0d);
setRightAnchor(contentWrapper, 0d);
logsContent = new VBox();
logsContent.heightProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
contentWrapper.setVvalue((Double) newValue);
}
});
logsContent.setSpacing(5);
contentWrapper.setContent(logsContent);
}