This discussion is archived
1 Reply Latest reply: Jan 23, 2013 3:59 AM by 983777 RSS

How to properly resize a group

983777 Newbie
Currently Being Moderated
I have following problem:
To fit a group properly into a pane I want to resize it. Currently, I use setScale.. . The size changes, however the bounds remain the same.

What is the correct way to achieve that?

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class JavaFXApplication1 extends Application {
    public void start(Stage primaryStage) {
        HBox root = new HBox();
        VBox left = new VBox();
        //create a titled pane with the max width of 100
        TitledPane tp = new TitledPane();        
        StackPane stackPane = new StackPane();
       //just a second node beneth the Titled Pane   
        root.getChildren().add(new Button("Test"));
       // now create a larger circle, scale it down
       // and add it to the stackpane within the titdled pane
       Group gnote = new Group();        
       Circle cleft = new Circle(100,Color.GOLDENROD);
        Scene scene = new Scene(root, 300, 250);        
        primaryStage.setTitle("Hello World!");
Edited by: skauf on 17.01.2013 07:29


  • Correct Answers - 10 points
  • Helpful Answers - 5 points