Tuesday, January 31, 2012

JavaFX exercise: Reflection effect

Reflection effect
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javafx_extext;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.Reflection;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author erix7
*/
public class JavaFX_exText 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);
  
     Reflection reflection = new Reflection();
  
     Text text = new Text(50, 50, "Serif");
     text.setFill(Color.RED);
     text.setFont(Font.font("Serif", 20));
     text.setEffect(reflection);
  
     Text text2 = new Text(50, 100, "SanSerif");
     text2.setFill(Color.GREEN);
     text2.setFont(Font.font("SanSerif", 30));
     text2.setEffect(reflection);
  
     Text text3 = new Text(50, 150, "Monospaced");
     text3.setFill(Color.BLUE);
     text3.setFont(Font.font("Monospaced", 40));
     text3.setEffect(reflection);
  
     root.getChildren().add(text);
     root.getChildren().add(text2);
     root.getChildren().add(text3);
  
     primaryStage.setScene(scene);
     primaryStage.show();
 }
}


- JavaFX Reflection Effect

2 comments: