child z ordering
Kevin Rushforth
kevin.rushforth at oracle.com
Sat Apr 13 12:58:12 UTC 2019
See Parent::viewOrder.
-- Kevin
On 4/12/2019 12:32 PM, James Dunsdon wrote:
> Hi,
>
> I'm wondering if there is any consideration towards being able to
> modify child Z ordering. Currently it only seems based on add order.
> There are a few use cases where slight overlapping might be desired in
> which case z ordering should be independently controllable of layout
> order. toFront(), toBack() only seem to work with Groups. I've given a
> code example of a use case below. My current workaround is to use
> rotations to created the desired effect.
>
>
> import javafx.application.Application;
> import javafx.geometry.Pos;
> import javafx.scene.Node;
> import javafx.scene.Parent;
> import javafx.scene.Scene;
> import javafx.scene.layout.HBox;
> import javafx.scene.layout.VBox;
> import javafx.scene.paint.Color;
> import javafx.scene.shape.Circle;
> import javafx.scene.shape.Rectangle;
> import javafx.stage.Stage;
>
> public class Main extends Application {
>
> @Override
> public void start(Stage primaryStage) throws Exception{
> Parent root = new VBox(createDefaultBehavior(),
> createPreferredBehavior());
> primaryStage.setTitle("Hello World");
> primaryStage.setScene(new Scene(root, 300, 275));
> primaryStage.show();
> }
>
> private Node createDefaultBehavior(){
> HBox box = new HBox(createCircle(), createRectangle());
> box.setAlignment(Pos.CENTER_LEFT);
> box.setSpacing(-10);
> return box;
> }
>
> /*
> in this case since we are using symmetric shapes the node
> rotations are unnecessary,
> however they would be required for most content
> */
> private Node createPreferredBehavior(){
> Node circle = createCircle();
> circle.setRotate(-180);
> Node rectangle = createRectangle();
> rectangle.setRotate(-180);
> HBox box = new HBox(rectangle, circle);
> box.setAlignment(Pos.CENTER_RIGHT);
> box.setRotate(180);
> box.setSpacing(-10);
> return box;
> }
>
> private Node createCircle(){
> Circle circle = new Circle(30, Color.RED);
> circle.setStroke(Color.GOLDENROD);
> circle.setStrokeWidth(4.0);
> return circle;
> }
>
> private Node createRectangle(){
> Rectangle rectangle = new Rectangle(100, 40, Color.GREEN);
> rectangle.setStroke(Color.GOLDENROD);
> rectangle.setStrokeWidth(4.0);
> return rectangle;
> }
>
>
> public static void main(String[] args) {
> launch(args);
> }
> }
>
>
> Thanks,
>
> James Dunsdon
>
> (nervous first time poster)
>
>
>
More information about the openjfx-dev
mailing list