document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2. import javafx.application.Application;
  3. import javafx.geometry.Insets;
  4. import javafx.scene.Scene;
  5. import javafx.scene.effect.DropShadow;
  6. import javafx.scene.effect.GaussianBlur;
  7. import javafx.scene.effect.InnerShadow;
  8. import javafx.scene.effect.Reflection;
  9. import javafx.scene.layout.VBox;
  10. import javafx.scene.paint.Color;
  11. import javafx.scene.text.Font;
  12. import javafx.scene.text.FontWeight;
  13. import javafx.scene.text.Text;
  14.  
  15. import javafx.stage.Stage;
  16.  
  17. /**
  18.  *
  19.  * @author zoranpavlovic.blogspot.com
  20.  */
  21. public class TextMain extends Application {
  22.     /**
  23.      * @param args
  24.      *            the command line arguments
  25.      */
  26.     public static void main(String[] args) {
  27.         Application.launch(args);
  28.     }
  29.  
  30.     @Override
  31.     public void start(Stage primaryStage) {
  32.         primaryStage.setTitle("Working with Text and Text Effects");
  33.  
  34.         // Creating VBOX
  35.         VBox vb = new VBox();
  36.         vb.setPadding(new Insets(10, 50, 50, 50));
  37.         vb.setSpacing(20);
  38.  
  39.         // Reflection effect
  40.         Reflection r = new Reflection();
  41.         r.setFraction(0.7f);
  42.         Text txtReflection = new Text("Reflection");
  43.         txtReflection.setFill(Color.RED);
  44.         txtReflection.setFont(Font.font(null, FontWeight.BOLD, 36));
  45.         txtReflection.setEffect(r);
  46.  
  47.         // DropShadow effect
  48.         DropShadow dropShadow = new DropShadow();
  49.         dropShadow.setOffsetX(5);
  50.         dropShadow.setOffsetY(5);
  51.         Text txtDropShadow = new Text("DropShadow");
  52.         txtDropShadow.setFill(Color.RED);
  53.         txtDropShadow.setFont(Font.font(null, FontWeight.BOLD, 36));
  54.         txtDropShadow.setEffect(dropShadow);
  55.  
  56.         // Blur text
  57.         Text txtBlur = new Text();
  58.         txtBlur.setText("Blurry Text with JavaFX 2");
  59.         txtBlur.setFill(Color.RED);
  60.         txtBlur.setFont(Font.font(null, FontWeight.BOLD, 36));
  61.         txtBlur.setEffect(new GaussianBlur());
  62.  
  63.         // InnerShadow
  64.         InnerShadow is = new InnerShadow();
  65.         Text txtInnerShadow = new Text();
  66.         txtInnerShadow.setEffect(is);
  67.         txtInnerShadow.setText("InnerShadow");
  68.         txtInnerShadow.setFill(Color.RED);
  69.         txtInnerShadow.setFont(Font.font(null, FontWeight.BOLD, 36));
  70.  
  71.         // Adding text to StackPane
  72.         vb.getChildren().addAll(txtDropShadow, txtBlur, txtInnerShadow,
  73.                 txtReflection);
  74.  
  75.         // Adding StackPane to the scene
  76.         Scene scene = new Scene(vb);
  77.         primaryStage.setScene(scene);
  78.         primaryStage.show();
  79.     }
  80. }
');