Example usage for javafx.scene.paint Color GREEN

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

Introduction

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

Prototype

Color GREEN

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

Click Source Link

Document

The color green with an RGB value of #008000

Usage

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<Rectangle> cmb = new ComboBox<Rectangle>();
    cmb.getItems().addAll(new Rectangle(10, 10, Color.RED), new Rectangle(10, 10, Color.GREEN),
            new Rectangle(10, 10, Color.BLUE));

    gridpane.add(cmb, 2, 0);/* w w  w .j a va2 s .  com*/

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

    primaryStage.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//w  w w . j a va  2s. c om
        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(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// w ww. j a va2s .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 stage) {
    Circle circle = new Circle(40);
    circle.setFill(Color.RED);/*from  w ww.  j  av  a 2  s .c  o m*/
    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

private Parent createRoot() {
    Rectangle node1 = RectangleBuilder.create().x(-150).y(-150).translateZ(-100).width(200).height(200)
            .fill(Color.RED).build();

    Rectangle node2 = RectangleBuilder.create().x(-100).y(-100).width(200).height(200).fill(Color.GREEN)
            .build();//from  w w  w . jav  a 2s  . co  m

    Rectangle node3 = RectangleBuilder.create().x(-50).y(-50).translateZ(100).width(200).height(200)
            .fill(Color.BLUE).build();

    return GroupBuilder.create().children(node1, node2, node3).translateX(250).translateY(250).build();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Text t1 = new Text("Drop Shadow!");
    t1.setFont(Font.font(24));//  ww w.  j  a  v a 2  s  . com
    t1.setEffect(new DropShadow());

    Text t2 = new Text("Blur!");
    t2.setFont(Font.font(24));
    t2.setEffect(new BoxBlur());

    Text t3 = new Text("Glow!");
    t3.setFont(Font.font(24));
    t3.setEffect(new Glow());

    Text t4 = new Text("Bloom!");
    t4.setFont(Font.font("Arial", FontWeight.BOLD, 24));
    t4.setFill(Color.WHITE);
    t4.setEffect(new Bloom(0.10));

    Rectangle rect = new Rectangle(100, 30, Color.GREEN);
    StackPane spane = new StackPane(rect, t4);

    HBox root = new HBox(t1, t2, t3, spane);
    root.setSpacing(20);

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Applying Effects");
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 200, 200);
    ComboBox<String> myComboBox = new ComboBox<String>();
    myComboBox.getItems().addAll("A", "B", "C", "D", "E");
    myComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
        @Override/*  w w  w .  ja  v a2s . c o m*/
        public ListCell<String> call(ListView<String> param) {
            final ListCell<String> cell = new ListCell<String>() {
                {
                    super.setPrefWidth(100);
                }

                @Override
                public void updateItem(String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        setText(item);
                        if (item.contains("A")) {
                            setTextFill(Color.RED);
                        } else if (item.contains("B")) {
                            setTextFill(Color.GREEN);
                        } else {
                            setTextFill(Color.BLACK);
                        }
                    } else {
                        setText(null);
                    }
                }
            };
            return cell;
        }
    });
    Group root = (Group) scene.getRoot();
    root.getChildren().add(myComboBox);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("ComboBoxSample");
    Scene scene = new Scene(new Group(), 450, 250);

    ComboBox emailComboBox = new ComboBox();
    emailComboBox.getItems().addAll("A", "B", "C", "D", "E");
    emailComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
        @Override/*from   w ww  . j  a v  a  2  s.  c  o m*/
        public ListCell<String> call(ListView<String> param) {
            final ListCell<String> cell = new ListCell<String>() {
                {
                    super.setPrefWidth(100);
                }

                @Override
                public void updateItem(String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        setText(item);
                        if (item.contains("A")) {
                            setTextFill(Color.RED);
                        } else if (item.contains("B")) {
                            setTextFill(Color.GREEN);
                        } else {
                            setTextFill(Color.BLACK);
                        }
                    } else {
                        setText(null);
                    }
                }
            };
            return cell;
        }

    });

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 260);

    // circles//w w w . j a  v  a2 s . c  o m
    Circle redCircle = createCircle(100, 50, 30, Color.RED);
    Circle blueCircle = createCircle(20, 150, 20, Color.BLUE);
    Circle greenCircle = createCircle(40, 100, 40, Color.GREEN);

    Line line1 = connect(redCircle, blueCircle);
    Line line2 = connect(redCircle, greenCircle);
    Line line3 = connect(greenCircle, blueCircle);

    // add the circles
    root.getChildren().add(redCircle);
    root.getChildren().add(blueCircle);
    root.getChildren().add(greenCircle);

    // add the lines
    root.getChildren().add(line1);
    root.getChildren().add(line2);
    root.getChildren().add(line3);

    // bring the circles to the front of the lines
    redCircle.toFront();
    blueCircle.toFront();
    greenCircle.toFront();

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

From source file:com.shootoff.session.io.JSONSessionReader.java

public Map<String, List<Event>> load() {
    Map<String, List<Event>> events = new HashMap<String, List<Event>>();

    try {//from  w ww .j  ava  2 s  .co m
        JSONObject session = (JSONObject) new JSONParser()
                .parse(new InputStreamReader(new FileInputStream(sessionFile), "UTF-8"));

        JSONArray cameras = (JSONArray) session.get("cameras");
        @SuppressWarnings("unchecked")
        Iterator<JSONObject> itCameras = cameras.iterator();

        while (itCameras.hasNext()) {
            JSONObject camera = itCameras.next();

            String cameraName = (String) camera.get("name");
            events.put(cameraName, new ArrayList<Event>());

            JSONArray cameraEvents = (JSONArray) camera.get("events");
            @SuppressWarnings("unchecked")
            Iterator<JSONObject> itEvents = cameraEvents.iterator();

            while (itEvents.hasNext()) {
                JSONObject event = itEvents.next();

                String eventType = (String) event.get("type");

                switch (eventType) {
                case "shot":
                    Color c;

                    if (event.get("color").equals("0xff0000ff")) {
                        c = Color.RED;
                    } else {
                        c = Color.GREEN;
                    }

                    Shot shot = new Shot(c, (double) event.get("x"), (double) event.get("y"),
                            (Long) event.get("shotTimestamp"), ((Long) event.get("markerRadius")).intValue());

                    boolean isMalfunction = (boolean) event.get("isMalfunction");

                    boolean isReload = (boolean) event.get("isReload");

                    Optional<Integer> targetIndex;
                    int index = ((Long) event.get("targetIndex")).intValue();
                    if (index == -1) {
                        targetIndex = Optional.empty();
                    } else {
                        targetIndex = Optional.of(index);
                    }

                    Optional<Integer> hitRegionIndex;
                    index = ((Long) event.get("hitRegionIndex")).intValue();
                    if (index == -1) {
                        hitRegionIndex = Optional.empty();
                    } else {
                        hitRegionIndex = Optional.of(index);
                    }

                    Optional<String> videoString = Optional.ofNullable((String) event.get("videos"));

                    events.get(cameraName).add(new ShotEvent(cameraName, (Long) event.get("timestamp"), shot,
                            isMalfunction, isReload, targetIndex, hitRegionIndex, videoString));
                    break;

                case "targetAdded":
                    events.get(cameraName).add(new TargetAddedEvent(cameraName, (Long) event.get("timestamp"),
                            (String) event.get("name")));
                    break;

                case "targetRemoved":
                    events.get(cameraName).add(new TargetRemovedEvent(cameraName, (Long) event.get("timestamp"),
                            ((Long) event.get("index")).intValue()));
                    break;

                case "targetResized":
                    events.get(cameraName)
                            .add(new TargetResizedEvent(cameraName, (Long) event.get("timestamp"),
                                    ((Long) event.get("index")).intValue(), (Double) event.get("newWidth"),
                                    (Double) event.get("newHeight")));
                    break;

                case "targetMoved":
                    events.get(cameraName).add(new TargetMovedEvent(cameraName, (Long) event.get("timestamp"),
                            ((Long) event.get("index")).intValue(), ((Long) event.get("newX")).intValue(),
                            ((Long) event.get("newY")).intValue()));
                    break;

                case "exerciseFeedMessage":
                    events.get(cameraName).add(new ExerciseFeedMessageEvent(cameraName,
                            (Long) event.get("timestamp"), (String) event.get("message")));
                    break;
                }
            }
        }

    } catch (IOException | ParseException e) {
        logger.error("Error reading JSON session", e);
    }

    return events;
}