document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import javafx.application.Application;
  2. import javafx.geometry.Insets;
  3. import javafx.scene.Scene;
  4. import javafx.scene.effect.BlurType;
  5. import javafx.scene.effect.DropShadow;
  6. import javafx.scene.layout.HBox;
  7. import javafx.scene.layout.VBox;
  8. import javafx.scene.paint.Color;
  9. import javafx.scene.text.Font;
  10. import javafx.scene.text.FontWeight;
  11. import javafx.scene.text.Text;
  12.  
  13. import javafx.stage.Stage;
  14.  
  15. /**
  16.  *
  17.  * @author zoranpavlovic.blogspot.com
  18.  */
  19. public class JavaFX2Text extends Application {
  20.     /**
  21.      * @param args
  22.      *            the command line arguments
  23.      */
  24.     public static void main(String[] args) {
  25.         Application.launch(args);
  26.     }
  27.  
  28.     @Override
  29.     public void start(Stage primaryStage) {
  30.         primaryStage.setTitle("Styling text");
  31.  
  32.         // Layouts stuff
  33.         VBox vb = new VBox();
  34.         vb.setPadding(new Insets(10, 50, 50, 50));
  35.         vb.setSpacing(20);
  36.         HBox hb = new HBox();
  37.  
  38.         // Text stuff
  39.         Text txtJava = new Text("Java");
  40.         txtJava.setFont(Font.font(null, FontWeight.BOLD, 72));
  41.  
  42.         Text txtFX2 = new Text("FX2");
  43.         txtFX2.setFont(Font.font(null, FontWeight.BOLD, 72));
  44.  
  45.         Text text1 = new Text("JavaFX2");
  46.         text1.setFont(Font.font(null, FontWeight.BOLD, 72));
  47.  
  48.         Text text2 = new Text("JavaFX2");
  49.         text2.setFont(Font.font(null, FontWeight.BOLD, 72));
  50.  
  51.         // DropShadow for txtFX2
  52.         DropShadow dropShadow = new DropShadow();
  53.         dropShadow.setColor(Color.DODGERBLUE);
  54.         dropShadow.setRadius(25);
  55.         dropShadow.setSpread(0.25);
  56.         dropShadow.setBlurType(BlurType.GAUSSIAN);
  57.         txtFX2.setEffect(dropShadow);
  58.  
  59.         // DropShadow for text1
  60.         DropShadow dropShadow2 = new DropShadow();
  61.         dropShadow2.setOffsetY(3.0);
  62.         dropShadow2.setOffsetX(3.0);
  63.         dropShadow2.setColor(Color.GREEN);
  64.         dropShadow2.setBlurType(BlurType.GAUSSIAN);
  65.         text1.setEffect(dropShadow2);
  66.  
  67.         // Adding ID\'s
  68.         text1.setId("JavaFX2");
  69.         txtJava.setId("Java");
  70.         txtFX2.setId("FX2");
  71.         text2.setId("text2");
  72.         vb.setId("root");
  73.  
  74.         // Adding Nodes to Layouts
  75.         hb.getChildren().addAll(txtJava, txtFX2);
  76.         vb.getChildren().addAll(hb, text1, text2);
  77.  
  78.         // Adding VBox to the scene
  79.         Scene scene = new Scene(vb);
  80.         scene.getStylesheets().add(
  81.                 getClass().getClassLoader().getResource("text.css")
  82.                         .toExternalForm());
  83.         primaryStage.setScene(scene);
  84.         primaryStage.show();
  85.     }
  86. }
');