Hi,
I have an Image and I want to display it with rounded borders and a drop shadow.
I tried to use a clip for the ImageView, but that also clips the shadow, leaving me with either the shadow OR the rounded corners.
Do you have any better idea? I basically want the shadow to have also rounded corners.
(The rectangle in my sample should be the ImageView actually)
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class TestApp2 extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
VBox root = new VBox();
root.setPadding(new Insets(20, 20, 20, 20));
Rectangle rectangle = new Rectangle(0, 0, 200, 200);
rectangle.setFill(Color.RED);
root.getChildren().add(rectangle);
Rectangle roundRect = new Rectangle(0, 0, 200, 200);
roundRect.setArcHeight(50);
roundRect.setArcWidth(50);
rectangle.setClip(roundRect);
rectangle.setEffect(new DropShadow());
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
Edited by: csh on 27.05.2013 06:54