Java Code Examples for javafx.scene.layout.AnchorPane#setPrefSize()

The following examples show how to use javafx.scene.layout.AnchorPane#setPrefSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnchorPaneSample.java    From marathonv5 with Apache License 2.0 8 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    AnchorPane anchorPane = new AnchorPane();

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    anchorPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle r1 = new Rectangle(14, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(45, 10, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(35, 14, Color.web("#349b00"));

    anchorPane.getChildren().addAll(r1, r2, r3);
    AnchorPane.setTopAnchor(r1, Double.valueOf(1));
    AnchorPane.setLeftAnchor(r1, Double.valueOf(1));
    AnchorPane.setTopAnchor(r2, Double.valueOf(20));
    AnchorPane.setLeftAnchor(r2, Double.valueOf(1));
    AnchorPane.setBottomAnchor(r3, Double.valueOf(1));
    AnchorPane.setRightAnchor(r3, Double.valueOf(5));

    sp.getChildren().addAll(rectangle, anchorPane);
    return new Group(sp);
}
 
Example 2
Source File: AnchorPaneSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    AnchorPane anchorPane = new AnchorPane();

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    anchorPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle r1 = new Rectangle(14, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(45, 10, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(35, 14, Color.web("#349b00"));

    anchorPane.getChildren().addAll(r1, r2, r3);
    AnchorPane.setTopAnchor(r1, Double.valueOf(1));
    AnchorPane.setLeftAnchor(r1, Double.valueOf(1));
    AnchorPane.setTopAnchor(r2, Double.valueOf(20));
    AnchorPane.setLeftAnchor(r2, Double.valueOf(1));
    AnchorPane.setBottomAnchor(r3, Double.valueOf(1));
    AnchorPane.setRightAnchor(r3, Double.valueOf(5));

    sp.getChildren().addAll(rectangle, anchorPane);
    return new Group(sp);
}
 
Example 3
Source File: LogAxisTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    AnchorPane pane = new AnchorPane(xAxisBottom, yAxisLeft);
    pane.setPadding(new Insets(10));
    pane.setPrefSize(400, 400);

    Scene scene = new Scene(pane);

    stage.setTitle("Title");
    stage.setScene(scene);
    stage.show();
}
 
Example 4
Source File: AxisTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    AnchorPane pane = new AnchorPane(xAxisBottom, xAxisTop, yAxisLeft, yAxisRight);
    pane.setPadding(new Insets(10));
    pane.setPrefSize(400, 400);

    Scene scene = new Scene(pane);

    stage.setTitle("Title");
    stage.setScene(scene);
    stage.show();
}
 
Example 5
Source File: Sampler.java    From desktoppanefx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    hostServices = getHostServices();
    //Creat main Pane Layout
    AnchorPane mainPane = new AnchorPane();
    mainPane.setPrefSize(800, 600);
    //Creat MDI Canvas Container
    DesktopPane desktopPane = new DesktopPane();
    //Fit it to the main Pane
    AnchorPane.setBottomAnchor(desktopPane, 0d);
    AnchorPane.setLeftAnchor(desktopPane, 0d);
    AnchorPane.setTopAnchor(desktopPane, 25d);//Button snapTo
    AnchorPane.setRightAnchor(desktopPane, 0d);
    //Put the container Into the main pane
    mainPane.getChildren().add(desktopPane);
    //Create a 'New MDI Window' Button
    Button newWindowButton = new Button("New Window");
    //set the button action

    newWindowButton.setOnAction(event -> {
        Node content = null;
        try {
            content = FXMLLoader.load(getClass().getResource("/MyContent.fxml"));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        count++;
        //Create a new window
        InternalWindow internalWindow = new InternalWindow("UniqueID" + count,
            new FontIcon("mdi-application:20:RED"),
            "Title " + count,
            content);
        //Add it to the container
        desktopPane.addInternalWindow(internalWindow);
    });
    //Put it into the main pane
    mainPane.getChildren().add(newWindowButton);

    primaryStage.setScene(new Scene(mainPane));
    primaryStage.show();
}