Saturday, June 18, 2016

41. DropShadow

A text node has the effect of DropShadow applied to it.


The shadow is blue, 50 to the right, 75 down, with blur of 5.


package ex41;
 
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.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
 
public class Ex41 extends Application {
 
    @Override
    public void start(Stage primaryStage) {
 
        Text text = new Text(50, 100, "The Drop!");
        text.setFont(new Font( "Georgia", 32 ));
        text.setLayoutX(100);
        text.setLayoutX(100);
        
        DropShadow shadow = new DropShadow();
        shadow.setColor(Color.BLUE);
        shadow.setOffsetX(50);
        shadow.setOffsetY(75);
        shadow.setRadius(5);
        text.setEffect(shadow);
                        
        Group root = new Group(text);
        Scene scene = new Scene(root, 400, 400);
        
        primaryStage.setTitle("Example 41. DropShadow");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
 
    public static void main(String[] args) {
        launch(args);
    }
}

This is the output:


No comments:

Post a Comment