Example usage for javafx.scene.paint Color RED

List of usage examples for javafx.scene.paint Color RED

Introduction

In this page you can find the example usage for javafx.scene.paint Color RED.

Prototype

Color RED

To view the source code for javafx.scene.paint Color RED.

Click Source Link

Document

The color red with an RGB value of #FF0000

Usage

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. java  2 s  .c  o m
    stage.setTitle("");

    VBox vb = new VBox();

    Pane canvas = new Pane();
    canvas.setStyle("-fx-background-color: black;");
    canvas.setPrefSize(200, 200);
    Circle circle = new Circle(50, Color.BLUE);
    circle.relocate(20, 20);
    Rectangle rectangle = new Rectangle(100, 100, Color.RED);
    rectangle.relocate(70, 70);
    canvas.getChildren().addAll(circle, rectangle);

    vb.getChildren().add(canvas);

    scene.setRoot(vb);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);/*w  ww.j  a  va2  s  .  c  o m*/

    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0);

    Text t = new Text();
    t.setText("JavaFX!");
    t.setFill(Color.RED);
    t.setFont(Font.font(null, FontWeight.BOLD, 90));
    t.setX(10.0);
    t.setY(10.0);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    box.getChildren().add(t);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    TextField fName = new TextField();
    TextField lName = new TextField();
    TextField salary = new TextField();

    marker = new Circle(5);
    marker.setManaged(false);/*from  w  w  w . jav  a 2 s .c  om*/
    marker.setFill(Color.RED);
    marker.setMouseTransparent(true);

    HBox hb1 = new HBox();
    HBox hb2 = new HBox();
    HBox hb3 = new HBox();
    hb1.getChildren().addAll(new Label("First Name:"), fName);
    hb2.getChildren().addAll(new Label("Last Name:"), lName);
    hb3.getChildren().addAll(new Label("Salary:"), salary);

    VBox root = new VBox();
    root.getChildren().addAll(hb1, hb2, hb3, marker);

    Scene scene = new Scene(root);

    scene.focusOwnerProperty().addListener((prop, oldNode, newNode) -> placeMarker(newNode));

    stage.setScene(scene);
    stage.setTitle("");
    stage.show();
}

From source file:Main.java

@Override
public void start(final Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 400, 300, Color.WHITE);
    GridPane gridpane = new GridPane();
    ComboBox<Color> cmb = new ComboBox<Color>();
    cmb.getItems().addAll(Color.RED, Color.GREEN, Color.BLUE);
    cmb.setCellFactory(new Callback<ListView<Color>, ListCell<Color>>() {
        @Override/*from   w w  w . jav  a  2  s  . c o  m*/
        public ListCell<Color> call(ListView<Color> p) {
            return new ListCell<Color>() {
                private final Rectangle rectangle;
                {
                    setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
                    rectangle = new Rectangle(10, 10);
                }

                @Override
                protected void updateItem(Color item, boolean empty) {
                    super.updateItem(item, empty);

                    if (item == null || empty) {
                        setGraphic(null);
                    } else {
                        rectangle.setFill(item);
                        setGraphic(rectangle);
                    }
                }
            };
        }
    });

    gridpane.add(cmb, 2, 0);

    root.getChildren().add(gridpane);
    primaryStage.setScene(scene);

    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    Group g = new Group();

    DropShadow ds1 = new DropShadow();
    ds1.setOffsetY(4.0);//from   w w  w.  jav  a2  s . c  o m

    Circle c = new Circle();
    c.setEffect(ds1);
    c.setCenterX(50.0);
    c.setCenterY(125.0);
    c.setRadius(30.0);
    c.setFill(Color.RED);
    c.setCache(true);

    g.getChildren().add(c);

    root.getChildren().add(g);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    DoubleProperty translate = new SimpleDoubleProperty();
    stage.setTitle("Hello JavaFX");
    Rectangle node1 = RectangleBuilder.create().x(0).y(0).width(10).height(10).fill(Color.RED).build();
    node1.translateXProperty().bind(translate);

    Parent parent = GroupBuilder.create().children(node1).translateX(250).translateY(250).build();
    stage.setScene(SceneBuilder.create().width(500).height(500).root(parent).build());
    stage.show();//from   ww w  . j  a v  a 2  s. co  m

    TimelineBuilder.create().cycleCount(Timeline.INDEFINITE)
            .keyFrames(new KeyFrame(Duration.seconds(0), new KeyValue(translate, -50)),
                    new KeyFrame(Duration.seconds(2), new KeyValue(translate, 250)))
            .build().play();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    Group g = new Group();

    DropShadow ds = new DropShadow();
    ds.setOffsetY(3.0);/*from w  w  w .  j a  va 2s . c  o m*/
    ds.setColor(Color.color(0.4, 0.4, 0.4));

    Text t = new Text();
    t.setEffect(ds);
    t.setCache(true);
    t.setX(10.0);
    t.setY(70.0);
    t.setFill(Color.RED);
    t.setText("JavaFX drop shadow...");
    t.setFont(Font.font(null, FontWeight.BOLD, 32));
    g.getChildren().add(t);

    root.getChildren().add(g);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(final Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 400, 300, Color.WHITE);

    GridPane gridpane = new GridPane();

    ComboBox<Color> cmb = new ComboBox<Color>();
    cmb.getItems().addAll(Color.RED, Color.GREEN, Color.BLUE);

    cmb.setCellFactory(new Callback<ListView<Color>, ListCell<Color>>() {
        @Override//from w w  w.  ja  v a  2s . co  m
        public ListCell<Color> call(ListView<Color> p) {
            return new ListCell<Color>() {
                private final Rectangle rectangle;
                {
                    setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
                    rectangle = new Rectangle(10, 10);
                }

                @Override
                protected void updateItem(Color item, boolean empty) {
                    super.updateItem(item, empty);

                    if (item == null || empty) {
                        setGraphic(null);
                    } else {
                        rectangle.setFill(item);
                        setGraphic(rectangle);
                    }
                }
            };
        }
    });

    gridpane.add(cmb, 2, 0);

    root.getChildren().add(gridpane);
    primaryStage.setScene(scene);

    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Colors");
    Group root = new Group();
    Scene scene = new Scene(root, 350, 300, Color.WHITE);

    Ellipse ellipse = new Ellipse(100, 50 + 70 / 2, 50, 70 / 2);
    RadialGradient gradient1 = RadialGradientBuilder.create().focusAngle(0).focusDistance(.1).centerX(80)
            .centerY(45).radius(120).proportional(false).cycleMethod(CycleMethod.NO_CYCLE)
            .stops(new Stop(0, Color.RED), new Stop(1, Color.BLACK)).build();

    ellipse.setFill(gradient1);// ww w  .  j a  va 2 s.c  o  m
    root.getChildren().add(ellipse);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

private void addBouncyBall(final Scene scene) {
    final Circle ball = new Circle(100, 100, 20);

    RadialGradient gradient1 = new RadialGradient(0, .1, 100, 100, 20, false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.RED), new Stop(1, Color.BLACK));

    ball.setFill(gradient1);/* www.ja va2  s .  com*/

    final Group root = (Group) scene.getRoot();
    root.getChildren().add(ball);

}