A Minimal JavaFX Presentation (In JavaFX)
A Minimal JavaFX Presentation (In JavaFX)
o7planning
All Tutorials Java Maven Gradle Servlet/Jsp Spring Struts2 Hibernate Java Web Service JavaFX SWT Oracle ADF Table Of Content
Android Python Swift C#
C/C++ Ruby Batch Database Report Client NodeJS Bootstrap OS Git SAP Others
1- JavaFX Group
“
JavaFX Image and ImageView Tutorial
JavaFX Label Tutorial
See also JavaFX RadioButton: JavaFX Hyperlink Tutorial
The example below, add some controls into a Group and apply motion blur effect for the Group, it will take effect with all
components within the Group.
GroupEffectDemo.java
1 package org.o7planning.javafx.group; ?
2
3 import javafx.application.Application;
4 import javafx.scene.Group;
5 import javafx.scene.Scene;
6 import javafx.scene.control.Button;
7 import javafx.scene.effect.MotionBlur;
8 import javafx.scene.paint.Color;
9 import javafx.scene.shape.Rectangle;
10 import javafx.scene.text.Font;
11 import javafx.scene.text.FontWeight;
12 import javafx.scene.text.Text;
13 import javafx.stage.Stage;
14
15 public class GroupEffectDemo extends Application {
16
17 @Override
18 public void start(Stage primaryStage) throws Exception {
19
20 Group root = new Group();
21
22 Rectangle rectangle = new Rectangle();
23 rectangle.setX(10);
24 rectangle.setY(30);
25 rectangle.setWidth(160);
26 rectangle.setHeight(80);
27 rectangle.setFill(Color.DARKBLUE);
28
29 Text text = new Text();
30 text.setText("Motion Blur!");
31 text.setFill(Color.RED);
32 text.setFont(Font.font("null", FontWeight.BOLD, 36));
33 text.setX(25);
34 text.setY(65);
35
36 Button button = new Button("My Button");
37
38 root.setCache(true);
39
40 // Create a MotionBlur effect
41 MotionBlur motionBlur = new MotionBlur();
42
43 // Sét effect for the Group.
44 root.setEffect(motionBlur);
45 // Translate X axis 50 pixel
46 root.setTranslateX(50);
47
48 // All components to Group
49 root.getChildren().addAll(rectangle, button, text);
50
51 Scene scene = new Scene(root, 250, 100);
52
53 primaryStage.setTitle("JavaFX Group Demo (o7planning.org)");
54 primaryStage.setScene(scene);
55 primaryStage.show();
56 }
57
58 public static void main(String[] args) {
59 Application.launch(args);
60 }
61
62 }
‘
See Also JavaFX Effects:
o7planning.org