Saturday, February 4, 2012

JavaFX 2.0 Exercise: Add Shadow effect

JavaFX 2.0 Add Shadow effect
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javafx_exdraw;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.stage.Stage;

/**
*
* @author erix7
*/
public class JavaFX_exDraw extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();
Scene scene = new Scene(root, 400, 300, Color.WHITE);

Ellipse ellipse = EllipseBuilder.create()
.centerX(200)
.centerY(150)
.radiusX(100)
.radiusY(75)
.strokeWidth(3)
.stroke(Color.BLACK)
.fill(Color.WHITE)
.build();

DropShadow dropShadow = new DropShadow();
dropShadow.setOffsetX(10);
dropShadow.setOffsetY(10);
dropShadow.setColor(Color.rgb(50, 50, 50, 0.7));
ellipse.setEffect(dropShadow);

root.getChildren().add(ellipse);

primaryStage.setScene(scene);
primaryStage.show();
}
}

1 comment:

  1. Extremely useful article. Thanx of your article as it helps me to solve my assignments.
    Regards
    Aditya

    ReplyDelete