List of usage examples for javafx.scene.shape Rectangle setFill
public final void setFill(Paint value)
From source file:Main.java
@Override public void start(Stage stage) { Circle circle = new Circle(40); circle.setFill(Color.RED);//from w w w. ja v a2 s .c om circle.setStroke(Color.BLACK); circle.setStrokeWidth(2.0); Rectangle rect = new Rectangle(120, 75); rect.setFill(Color.RED); // Create a line Line line = new Line(0, 0, 150, 50); line.setStrokeWidth(5.0); line.setStroke(Color.GREEN); // Create a parallelogram Polygon parallelogram = new Polygon(); parallelogram.getPoints().addAll(30.0, 0.0, 130.0, 0.0, 120.00, 50.0, 0.0, 50.0); parallelogram.setFill(Color.AZURE); parallelogram.setStroke(Color.BLACK); // Create a hexagon Polyline hexagon = new Polyline(100.0, 0.0, 120.0, 20.0, 110.0, 140.0, 100.0, 60.0, 80.0, 40.0, 80.0, 120.0, 100.0, 0.0); hexagon.setFill(Color.WHITE); hexagon.setStroke(Color.BLACK); // A CHORD arc with no fill and a stroke Arc arc = new Arc(0, 0, 50, 100, 0, 90); arc.setFill(Color.TRANSPARENT); arc.setStroke(Color.BLACK); arc.setType(ArcType.CHORD); // Add all shapes to an HBox HBox root = new HBox(circle, rect, line, parallelogram, hexagon, arc); root.setSpacing(10); root.setStyle("-fx-padding: 10;" + "-fx-border-style: solid inside;" + "-fx-border-width: 2;" + "-fx-border-insets: 5;" + "-fx-border-radius: 5;" + "-fx-border-color: blue;"); Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("2D Shapes"); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { final Group group = new Group(); Scene scene = new Scene(group, 300, 150); stage.setScene(scene);/*from w w w .ja va 2s . c o m*/ stage.setTitle("Sample"); Rectangle rect = new Rectangle(100, 40, 100, 100); rect.setArcHeight(50); rect.setArcWidth(50); rect.setFill(null); StrokeTransition st = new StrokeTransition(Duration.millis(3000), rect, Color.RED, Color.BLUE); st.setAutoReverse(true); st.play(); group.getChildren().add(rect); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 500, 200); stage.setScene(scene);//from ww w . ja v a 2 s .co m Rectangle rect = new Rectangle(100, 40, 100, 100); rect.setArcHeight(50); rect.setArcWidth(50); rect.setFill(Color.VIOLET); RotateTransition rt = new RotateTransition(Duration.millis(3000), rect); rt.setByAngle(180); rt.setAutoReverse(true); rt.play(); root.getChildren().add(rect); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 500, 200); stage.setScene(scene);//from w ww .ja v a2 s . c om Rectangle rect = new Rectangle(100, 40, 100, 100); rect.setArcHeight(50); rect.setArcWidth(50); rect.setFill(Color.VIOLET); ScaleTransition st = new ScaleTransition(Duration.millis(2000), rect); st.setByX(1.5f); st.setByY(1.5f); st.setAutoReverse(true); st.play(); root.getChildren().add(rect); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 260, 80); stage.setScene(scene);/*from ww w. jav a 2 s . c o m*/ VBox vb = new VBox(); Rectangle rect = new Rectangle(100, 40, 100, 100); rect.setArcHeight(50); rect.setArcWidth(50); rect.setFill(Color.VIOLET); RotateTransition rt = new RotateTransition(Duration.millis(3000), rect); rt.setByAngle(180); rt.setAutoReverse(true); SequentialTransition seqTransition = new SequentialTransition(new PauseTransition(Duration.millis(1000)), // wait a second rt); seqTransition.play(); vb.getChildren().add(rect); scene.setRoot(vb); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Sample"); stage.setWidth(300);//from w ww . j a va 2 s .co m stage.setHeight(190); VBox vbox = new VBox(); vbox.setLayoutX(20); vbox.setLayoutY(20); Rectangle rect = new Rectangle(100, 40, 100, 100); rect.setArcHeight(50); rect.setArcWidth(50); rect.setFill(Color.VIOLET); TranslateTransition tt = new TranslateTransition(Duration.millis(2000), rect); tt.setByX(200f); tt.setAutoReverse(true); tt.play(); vbox.getChildren().add(rect); vbox.setSpacing(10); ((Group) scene.getRoot()).getChildren().add(vbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Text Fonts"); Group g = new Group(); Scene scene = new Scene(g, 550, 250); Rectangle r = new Rectangle(); r.setX(10);//from ww w . j a va 2s .co m r.setY(10); r.setWidth(160); r.setHeight(80); r.setFill(Color.DARKBLUE); Text t = new Text(); t.setText("Bloom!"); t.setFill(Color.YELLOW); t.setFont(Font.font(null, FontWeight.BOLD, 36)); t.setX(25); t.setY(65); g.setCache(true); g.setEffect(new Bloom()); g.getChildren().add(r); g.getChildren().add(t); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Text Fonts"); Group g = new Group(); Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0)); Rectangle r = new Rectangle(); r.setX(10);/*www.j a v a2 s. co m*/ r.setY(10); r.setWidth(160); r.setHeight(80); r.setFill(Color.DARKBLUE); Text t = new Text(); t.setText("Bloom!"); t.setFill(Color.YELLOW); t.setFont(Font.font(null, FontWeight.BOLD, 36)); t.setX(25); t.setY(65); g.setCache(true); g.setEffect(new Bloom()); g.getChildren().add(r); g.getChildren().add(t); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 260, 80); stage.setScene(scene);/*w ww . jav a 2 s. co m*/ VBox vb = new VBox(); Rectangle rect = new Rectangle(100, 40, 100, 100); rect.setArcHeight(50); rect.setArcWidth(50); rect.setFill(Color.VIOLET); final Duration SEC_2 = Duration.millis(2000); final Duration SEC_3 = Duration.millis(3000); FadeTransition ft = new FadeTransition(SEC_3); ft.setFromValue(1.0f); ft.setToValue(0.3f); ft.setAutoReverse(true); TranslateTransition tt = new TranslateTransition(SEC_2); tt.setFromX(-100f); tt.setToX(100f); tt.setAutoReverse(true); RotateTransition rt = new RotateTransition(SEC_3); rt.setByAngle(180f); rt.setAutoReverse(true); ScaleTransition st = new ScaleTransition(SEC_2); st.setByX(1.5f); st.setByY(1.5f); st.setAutoReverse(true); ParallelTransition pt = new ParallelTransition(rect, ft, tt, rt, st); pt.play(); vb.getChildren().add(rect); scene.setRoot(vb); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 260, 80); stage.setScene(scene);//from w w w .j a v a 2 s.c o m Group g = new Group(); PerspectiveTransform pt = new PerspectiveTransform(); pt.setUlx(10.0); pt.setUly(10.0); pt.setUrx(310.0); pt.setUry(40.0); pt.setLrx(310.0); pt.setLry(60.0); pt.setLlx(10.0); pt.setLly(90.0); g.setEffect(pt); g.setCache(true); Rectangle r = new Rectangle(); r.setX(10.0); r.setY(10.0); r.setWidth(280.0); r.setHeight(80.0); r.setFill(Color.BLUE); Text t = new Text(); t.setX(20.0); t.setY(65.0); t.setText("JavaFX"); t.setFill(Color.YELLOW); t.setFont(Font.font(null, FontWeight.BOLD, 36)); g.getChildren().add(r); g.getChildren().add(t); scene.setRoot(g); stage.show(); }