Java Reference
In-Depth Information
figure 11-34  
As of now, you might appreciate the cleaner coding style and look of JavaFX, but still wonder what
the big deal is. Earlier, you read that JavaFX hardware accelerated graphics to allow for more spec-
tacular graphical applications as well. The following and final example (adapted from an Oracle
tutorial) shows this in action:
import static java.lang.Math.random;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.effect.BlendMode;
import javafx.scene.effect.BoxBlur;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.StrokeType;
import javafx.stage.Stage;
import javafx.util.Duration;
public class ScreenSaver extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Group root = new Group();
Scene scene = new Scene(root, 800, 600, Color.WHITE);
primaryStage.setScene(scene);
Search WWH ::




Custom Search