当前位置: 首页>>代码示例>>Java>>正文


Java ScrollPane.setPannable方法代码示例

本文整理汇总了Java中javafx.scene.control.ScrollPane.setPannable方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollPane.setPannable方法的具体用法?Java ScrollPane.setPannable怎么用?Java ScrollPane.setPannable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.ScrollPane的用法示例。


在下文中一共展示了ScrollPane.setPannable方法的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);
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:26,代码来源:TabPaneWithControl.java

示例2: start

import javafx.scene.control.ScrollPane; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
    if (primaryStage == null) {
        return;
    }

    /* Layers */
    Group backgroundLayer = new Group();
    Group statesLayer = new Group();
    Group selectionLayer = new Group();

    Pane paintingPane = new Pane(backgroundLayer, statesLayer, selectionLayer);
    paintingPane.setStyle(BACKGROUND_STYLE);

    /* Top-level */
    Pane contentPane = new Pane(paintingPane);
    contentPane.minWidthProperty().bind(contentPane.prefWidthProperty());
    contentPane.maxWidthProperty().bind(contentPane.prefWidthProperty());

    ScrollPane scrollPane = new ScrollPane(contentPane);
    scrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS);
    scrollPane.setHbarPolicy(ScrollBarPolicy.ALWAYS);
    scrollPane.setFitToHeight(true);
    scrollPane.setFitToWidth(true);
    scrollPane.setPannable(true);

    BorderPane borderPane = new BorderPane(scrollPane);

    primaryStage.setScene(new Scene(borderPane));
    primaryStage.show();
    primaryStage.setHeight(500);
    primaryStage.setWidth(500);

    contentPane.setPrefHeight(200);
    contentPane.setPrefWidth(PANE_WIDTH);

    /* Bind painting pane's height to the content pane */
    paintingPane.minHeightProperty().bind(contentPane.minHeightProperty());
    paintingPane.prefHeightProperty().bind(contentPane.prefHeightProperty());
    paintingPane.maxHeightProperty().bind(contentPane.maxHeightProperty());

    /* We set painting's pane width programmatically */
    paintingPane.minWidthProperty().bind(paintingPane.prefWidthProperty());
    paintingPane.maxWidthProperty().bind(paintingPane.prefWidthProperty());

    paintingPane.setPrefWidth(2000);
    double x = PANE_WIDTH - 2000;
    System.out.println(x);
    paintingPane.relocate(x, 0);

    drawBackground(backgroundLayer, paintingPane);
    drawRectangles(statesLayer);
    drawSelection(selectionLayer, paintingPane);
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:55,代码来源:UiModelApp2.java

示例3: start

import javafx.scene.control.ScrollPane; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
    if (primaryStage == null) {
        return;
    }

    /* Layers */
    Group backgroundLayer = new Group();
    Group statesLayer = new Group();
    Group selectionLayer = new Group();

    /* Top-level */
    Pane contentPane = new Pane(backgroundLayer, statesLayer, selectionLayer);
    contentPane.minWidthProperty().bind(contentPane.prefWidthProperty());
    contentPane.maxWidthProperty().bind(contentPane.prefWidthProperty());
    contentPane.setStyle(BACKGROUND_STYLE);

    ScrollPane scrollPane = new ScrollPane(contentPane);
    scrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS);
    scrollPane.setHbarPolicy(ScrollBarPolicy.ALWAYS);
    scrollPane.setFitToHeight(true);
    scrollPane.setFitToWidth(true);
    scrollPane.setPannable(true);

    BorderPane borderPane = new BorderPane(scrollPane);

    primaryStage.setScene(new Scene(borderPane));
    primaryStage.show();
    primaryStage.setHeight(500);
    primaryStage.setWidth(500);

    contentPane.setPrefHeight(200);
    contentPane.setPrefWidth(PANE_WIDTH);

    drawBackground(backgroundLayer, contentPane);
    drawRectangles(statesLayer);
    drawSelection(selectionLayer, contentPane);
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:39,代码来源:UiModelApp.java

示例4: productbyType

import javafx.scene.control.ScrollPane; //导入方法依赖的package包/类
public static BorderPane productbyType(String type) {

        BorderPane products = new BorderPane();
        products.setPadding(new Insets(10,20,10,20));

        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;

        String query = DBUtils.prepareSelectQuery(" * ",
                " classroomflipkart.productdetail AS T ," +
                        " ( "+ DBUtils.prepareSelectQuery("productId",
                                " classroomflipkart.homeproducts ",
                                "type = '"+type+"'")+
                        " ) AS S",
                " T.productId = S.productId ");

        try {
            con = DBUtils.getConnection();
            stmt = con.prepareStatement(query);
            rs = stmt.executeQuery();

            rs.last();
            int size = rs.getRow();

            if (size>0){
                rs.beforeFirst();

                Label title = new Label(type+"");
                title.setFont(Font.font("Open Sans", FontWeight.BOLD,17));
                title.setPadding(new Insets(10));
                title.setAlignment(Pos.CENTER);

                HBox productList = new HBox(20);
                productList.setAlignment(Pos.CENTER);

                while (rs.next()) {
                    String productId = rs.getString("productId");
                    String productName = rs.getString("productName");
                    String newPrice = rs.getString("newPrice");
                    String oldPrice = rs.getString("oldPrice");
                    String category = rs.getString("category");
                    String subcategory = rs.getString("subcategory");
                    String imageName = rs.getString("imageName");
                    String productAvailability = rs.getString("productAvailability");

                    productList.getChildren().add(productDetail.productByType(productId,productName,newPrice,oldPrice,category,subcategory,imageName, productAvailability));
                }

                ScrollPane proScroller = new ScrollPane(productList);
                proScroller.setFitToHeight(true);
                proScroller.setFitToWidth(true);
                proScroller.setPannable(true);
                proScroller.setPadding(new Insets(0,0,30,0));

                StackPane titlePane = new StackPane(title);
                titlePane.setAlignment(Pos.CENTER);

                StackPane productPane = new StackPane(proScroller);
                productPane.setAlignment(Pos.CENTER);

                products.setTop(titlePane);
                products.setCenter(productPane);
            }


        } catch (Exception e) {
            products.setCenter(new Label(e.getMessage()));
            e.printStackTrace();
        } finally {
            DBUtils.closeAll(rs, stmt, con);
            return products;
        }
    }
 
开发者ID:madHEYsia,项目名称:ClassroomFlipkart,代码行数:75,代码来源:fetchProducts.java

示例5: start

import javafx.scene.control.ScrollPane; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws MalformedURLException {
    Region zoomTarget = createContent();
    zoomTarget.setPrefSize(1000, 1000);
    zoomTarget.setOnDragDetected(evt -> {
        Node target = (Node) evt.getTarget();
        while (target != zoomTarget && target != null) {
            target = target.getParent();
        }
        if (target != null) {
            target.startFullDrag();
        }
    });

    Group group = new Group(zoomTarget);

    // stackpane for centering the content, in case the ScrollPane viewport
    // is larget than zoomTarget
    StackPane content = new StackPane(group);
    group.layoutBoundsProperty().addListener((observable, oldBounds, newBounds) -> {
        // keep it at least as large as the content
        content.setMinWidth(newBounds.getWidth());
        content.setMinHeight(newBounds.getHeight());
    });

    ScrollPane scrollPane = new ScrollPane(content);
    scrollPane.setPannable(true);
    scrollPane.viewportBoundsProperty().addListener((observable, oldBounds, newBounds) -> {
        // use vieport size, if not too small for zoomTarget
        content.setPrefSize(newBounds.getWidth(), newBounds.getHeight());
    });

    content.setOnScroll(evt -> {
        if (evt.isControlDown()) {
            evt.consume();

            final double zoomFactor = evt.getDeltaY() > 0 ? 1.2 : 1 / 1.2;

            Bounds groupBounds = group.getLayoutBounds();
            final Bounds viewportBounds = scrollPane.getViewportBounds();

            // calculate pixel offsets from [0, 1] range
            double valX = scrollPane.getHvalue() * (groupBounds.getWidth() - viewportBounds.getWidth());
            double valY = scrollPane.getVvalue() * (groupBounds.getHeight() - viewportBounds.getHeight());

            // convert content coordinates to zoomTarget coordinates
            Point2D posInZoomTarget = zoomTarget.parentToLocal(group.parentToLocal(new Point2D(evt.getX(), evt.getY())));

            // calculate adjustment of scroll position (pixels)
            Point2D adjustment = zoomTarget.getLocalToParentTransform().deltaTransform(posInZoomTarget.multiply(zoomFactor - 1));

            // do the resizing
            zoomTarget.setScaleX(zoomFactor * zoomTarget.getScaleX());
            zoomTarget.setScaleY(zoomFactor * zoomTarget.getScaleY());

            // refresh ScrollPane scroll positions & content bounds
            scrollPane.layout();

            // convert back to [0, 1] range
            // (too large/small values are automatically corrected by ScrollPane)
            groupBounds = group.getLayoutBounds();
            scrollPane.setHvalue((valX + adjustment.getX()) / (groupBounds.getWidth() - viewportBounds.getWidth()));
            scrollPane.setVvalue((valY + adjustment.getY()) / (groupBounds.getHeight() - viewportBounds.getHeight()));
        }
    });

    StackPane left = new StackPane(new Label("Left Menu"));
    SplitPane root = new SplitPane(left, scrollPane);

    Scene scene = new Scene(root, 800, 600);

    primaryStage.setScene(scene);
    primaryStage.show();
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:75,代码来源:ZoomExample.java


注:本文中的javafx.scene.control.ScrollPane.setPannable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。