I have a program short that puts Rotated objects inside a VBox. I want the VBox to adjust it's vertical size based on the rotation. In the following example the Text objects should NOT touch:
But they do. The code to generate this is below:
package metcarob.com.soavisualise;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class TestAppForRotate extends Application {
@Override
public void start(final Stage primaryStage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
VBox vbox = new VBox();
root.getChildren().add(vbox);
Group g = null;
Text t = null;
StackPane p = null;
for (int c=0;c<3;c++) {
g = new Group();
t = new Text("Test " + Integer.toString(c));
p = new StackPane();
p.getChildren().add(t);
p.setStyle("-fx-background-color: white; -fx-border-color: orange; -fx-border-width: 3;");
g.getChildren().add(p);
g.setRotate(c * 35);
vbox.getChildren().add(g);
}
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
In this configuration I have Text inside StackPane inside Group the whole Group is rotated and added to the VBox (In this example I need the Orange Box to rotate as well as the Text)
Any ideas on how to get this to work? Robert