Text Reflection Effect in Java Fx2.0


In this Example you can easily come to know that how to apply a background color to your Java Fx 2.0 application.Here i have used various text effect to show the possible text reflection in javaFx 2.0.

// Comment
package javatextreflection;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.Reflection;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
 *
 * @author allinalljava.blogspot.com
 */
public class Javatextreflection extends Application {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
    
    @Override
    public void start(Stage primaryStage) {
        
primaryStage.setTitle("Reflection Example");
Group root = new Group();
Scene scene = new Scene(root,300, 300, Color.BLACK);


Text text1 = new Text(10, 50, "Welcome to JavaFX2.0");
Font monoFont = Font.font("Monospaced", 30);
text1.setFont(monoFont);
text1.setFill(Color.AQUA);
root.getChildren().add(text1);
Text text2 = new Text(100, 150, "Reflection");
Font monoF = Font.font("Monospaced", 22);
text2.setFont(monoF);
text2.setFill(Color.ANTIQUEWHITE);
root.getChildren().add(text2);
Reflection reflECT = new Reflection();
reflECT.setFraction(0.8f);
text1.setEffect(reflECT);
text2.setEffect(reflECT);
primaryStage.setScene(scene);
primaryStage.show();
    }
}





Output

raja P Web Developer

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...