JavaFX How to - Create Glowing Text








Question

We would like to know how to create Glowing Text.

Answer

//  www .jav  a  2  s.c  om
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.Effect;
import javafx.scene.effect.Glow;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Main extends Application
{
   @Override
   public void start(final Stage stage) throws Exception
   {
      Group rootGroup = new Group();
      Scene scene =new Scene(rootGroup, 800, 400);
 
      Text text1 = new Text(25, 25, "java2s.com");
      text1.setFill(Color.CHOCOLATE);
      text1.setFont(Font.font(java.awt.Font.MONOSPACED, 35));
      
      Effect glow = new Glow(1.0);
      text1.setEffect(glow);
      
      rootGroup.getChildren().add(text1);

      stage.setScene(scene);
      stage.show();
   }
   public static void main(final String[] arguments)
   {
      Application.launch(arguments);
   }
}