當前位置: 首頁>>代碼示例>>Java>>正文


Java Pane.setPrefSize方法代碼示例

本文整理匯總了Java中javafx.scene.layout.Pane.setPrefSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Pane.setPrefSize方法的具體用法?Java Pane.setPrefSize怎麽用?Java Pane.setPrefSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.layout.Pane的用法示例。


在下文中一共展示了Pane.setPrefSize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: animiereRechteck

import javafx.scene.layout.Pane; //導入方法依賴的package包/類
public static Pane animiereRechteck() {

        Random random = new Random();

        Pane animationPane = new Pane();
        animationPane.setPrefSize(500,200);

        Rectangle rect = new Rectangle(75, 75, 100, 50);
        animationPane.getChildren().add(rect);

        Timeline timeline = new Timeline();
        timeline.setCycleCount(Timeline.INDEFINITE);
        timeline.setAutoReverse(true);

        KeyValue kVMoveX = new KeyValue(rect.xProperty(), random.nextInt(200) + 200);
        KeyValue kVRotate = new KeyValue(rect.rotateProperty(), random.nextInt(360) + 180);
        KeyValue kVArcHeight = new KeyValue(rect.arcHeightProperty(), 60);
        KeyValue kVArcWidth = new KeyValue(rect.arcWidthProperty(), 60);
        
        KeyFrame keyFrame = new KeyFrame(Duration.millis(random.nextInt(2000) + 2000), kVMoveX, kVRotate, kVArcHeight, kVArcWidth);

        timeline.getKeyFrames().add(keyFrame);
        timeline.play();

        return animationPane;
    }
 
開發者ID:CAPTNCAPS,項目名稱:java.IF17wi,代碼行數:27,代碼來源:Rechteck.java

示例2: setup

import javafx.scene.layout.Pane; //導入方法依賴的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"));
}
 
開發者ID:iAmGio,項目名稱:jrfl,代碼行數:18,代碼來源:Jrfl.java

示例3: ControlsPaneController

import javafx.scene.layout.Pane; //導入方法依賴的package包/類
public ControlsPaneController(UIToolBox toolBox) {
    this.toolBox = toolBox;

    toolBox.getEventBus()
            .toObserverable()
            .ofType(MediaControlsChangedEvent.class)
            .subscribe(e -> updateMediaControlPane(e.get()));

    emptyControlsPane = new Pane();
    emptyControlsPane.setPrefSize(440, 80);
    emptyControlsPane.setMaxSize(440, 80);
    emptyControlsPane.setMinSize(440, 80);

    Runtime.getRuntime()
            .addShutdownHook(new Thread(() -> saveDividerPositions(splitPaneKey, getRoot())));
}
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:17,代碼來源:ControlsPaneController.java

示例4: animiereBall

import javafx.scene.layout.Pane; //導入方法依賴的package包/類
public Pane animiereBall() {
    animationPane = new Pane();
    animationPane.setPrefSize(pb, ph);

    circle = new Circle(x, y, r, color);

    Timeline timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);

    KeyFrame moveBall = new KeyFrame(Duration.millis(intervall), new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            if (((circle.getCenterX() + dx < r) && (dx < 0)) || ((circle.getCenterX() + dx > animationPane.getWidth() - r) && (dx > 0))) {
                dx = -dx;
            }
            circle.setCenterX(circle.getCenterX() + dx);
            
            if (((circle.getCenterY() + dy < r) && (dy < 0)) || ((circle.getCenterY() + dy > animationPane.getHeight() - r) && (dy > 0))) {
                dy = -dy;
            }
            circle.setCenterY(circle.getCenterY() + dy);
        }
    });

    timeline.getKeyFrames().add(moveBall);
    timeline.play();

    HBox hBox = this.navigiereAnimation(timeline);

    animationPane.getChildren().addAll(circle, hBox);

    return animationPane;
}
 
開發者ID:CAPTNCAPS,項目名稱:java.IF17wi,代碼行數:33,代碼來源:Ball.java

示例5: start

import javafx.scene.layout.Pane; //導入方法依賴的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();
    }
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:57,代碼來源:Example2.java


注:本文中的javafx.scene.layout.Pane.setPrefSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。