Tuesday, June 5, 2012

Drop shadow on text, using JavaFX

Drop shadow on text, using JavaFX


package javafx_text;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_Text extends Application {

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

@Override
public void start(Stage primaryStage) {

DropShadow shadow = new DropShadow();
shadow.setOffsetX(5.0);
shadow.setOffsetY(5.0);
shadow.setColor(Color.GRAY);

Text text = new Text();
text.setText("Text with Shadow (using JavaFX)");
text.setEffect(shadow);

StackPane root = new StackPane();
root.getChildren().add(text);

Scene scene = new Scene(root, 300, 250);

primaryStage.setTitle("java-buddy.blogspot.com");
primaryStage.setScene(scene);
primaryStage.show();
}
}


Compare:
- Drop shadow on text, using FXML

No comments:

Post a Comment