Difference between revisions of "Some Scene examples"
From MyWiki
(Created page with "A basic application frame : <source lang="java"> package scenegraphdemo; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; impor...") |
|||
| Line 17: | Line 17: | ||
Group root = new Group(); | Group root = new Group(); | ||
Scene scene = new Scene(root, 500, 500, Color.BLACK); | Scene scene = new Scene(root, 500, 500, Color.BLACK); | ||
| + | stage.setTitle("JavaFX Scene Graph Demo"); | ||
| + | stage.setScene(scene); | ||
| + | stage.show(); | ||
| + | } | ||
| + | |||
| + | public static void main(String[] args) { | ||
| + | launch(args); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | </source> | ||
| + | |||
| + | Adding a leaf node : | ||
| + | <source lang="java"> | ||
| + | |||
| + | package scenegraphdemo; | ||
| + | |||
| + | import javafx.application.Application; | ||
| + | import javafx.scene.Group; | ||
| + | import javafx.scene.Scene; | ||
| + | import javafx.scene.paint.Color; | ||
| + | import javafx.scene.shape.Rectangle; | ||
| + | import javafx.stage.Stage; | ||
| + | |||
| + | public class Main extends Application { | ||
| + | |||
| + | @Override | ||
| + | public void start(Stage stage) { | ||
| + | Group root = new Group(); | ||
| + | Scene scene = new Scene(root, 500, 500, Color.BLACK); | ||
| + | |||
| + | Rectangle r = new Rectangle(25,25,250,250); | ||
| + | r.setFill(Color.BLUE); | ||
| + | root.getChildren().add(r); | ||
| + | |||
stage.setTitle("JavaFX Scene Graph Demo"); | stage.setTitle("JavaFX Scene Graph Demo"); | ||
stage.setScene(scene); | stage.setScene(scene); | ||
Revision as of 07:54, 15 July 2015
A basic application frame :
package scenegraphdemo; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 500, 500, Color.BLACK); stage.setTitle("JavaFX Scene Graph Demo"); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }
Adding a leaf node :
package scenegraphdemo; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 500, 500, Color.BLACK); Rectangle r = new Rectangle(25,25,250,250); r.setFill(Color.BLUE); root.getChildren().add(r); stage.setTitle("JavaFX Scene Graph Demo"); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }