0

My easy application has two layout panes. First is VBox pane. It is root node. Second pane is child pane (Pane layout). I want to use DropShadow effect for root pane only. I do it according to the documentation . Unfortunately I have the Drop shadow effect for both panes. For root and for child. Is it a bug or there is a way to set it for one pane only? I was trying to use pane.setEffect( null ) but without success. When I add some child to pane, the new node has shadow also.

I use JavaFX8 (Windows 7 - 64).

Thank you.

public void start( Stage stage )
{
        VBox vbox = new VBox();
        vbox.setPadding( new Insets( 30 ) );

        BorderStrokeStyle style = new BorderStrokeStyle( StrokeType.INSIDE, StrokeLineJoin.MITER, StrokeLineCap.BUTT, 10, 0, null );
        BorderStroke stroke = new BorderStroke( Color.BLUE, style, CornerRadii.EMPTY, new BorderWidths( 1 ), null );
        vbox.setBorder( new Border( stroke ) );

        DropShadow dropShadow = new DropShadow();
        dropShadow.setOffsetX( 10 );
        dropShadow.setOffsetY( 10 );
        vbox.setEffect( dropShadow );

        Pane pane = new Pane();
        pane.setBorder( new Border( stroke ) );

        pane.setPrefWidth( 500 );
        pane.setPrefHeight( 500 );

        vbox.getChildren().add( pane );

        stage.setScene( new Scene( vbox ) );
        stage.show();
}

addition:

Was trying to use css: vbox.setStyle( "-fx-effect: dropshadow(gaussian, gray, 10, 0.6, 10, 10);" ); The same shit - the effect was applied for both panes. ((

Uladzimir
  • 441
  • 5
  • 9
  • Have you tried setting the effect of the child pane with `pane.setEffect( null );`? – Matt C Apr 25 '16 at 15:03
  • Sure. Without success (( I will try to use css for shadow effect – Uladzimir Apr 25 '16 at 15:26
  • 1
    [http://stackoverflow.com/questions/20898947/add-dropshadow-only-to-border-of-grid-pane-javafx-2-2](http://stackoverflow.com/questions/20898947/add-dropshadow-only-to-border-of-grid-pane-javafx-2-2) – jns Apr 26 '16 at 02:18

1 Answers1

0

Here I am trying to answer to my own question.

I made some easy investigations and It looks like it is not a bug. It is an attempt to provide a real life behavior for a pane.

If a pane doesn't have non-transparent background - the all pane's children should have a shadow also (if the owner pane has it). On the other hand - if the pane has solid background, the children can't have a shadow. Till you put shadow specially.

So... You just need to provide a non-transparent background for pane, to avoid shadows for pane's children shapes and panes.

Sure, It would be good to notice it in the docemtntation.

Uladzimir
  • 441
  • 5
  • 9