@Override public void start(Stage primaryStage) { ImageView us = new ImageView(new Image("File:C:/Java/site/image/us.gif")); Label lb1 = new Label("US\n50 States", us); lb1.setStyle("-fx-border-color: green; -fx-border-width: 2"); lb1.setContentDisplay(ContentDisplay.BOTTOM); lb1.setTextFill(Color.RED); Label lb2 = new Label("Circle", new Circle(50, 50, 25)); lb2.setContentDisplay(ContentDisplay.TOP); lb2.setTextFill(Color.ORANGE); Label lb3 = new Label("Rectangle", new Rectangle(10, 10, 50, 25)); lb3.setContentDisplay(ContentDisplay.RIGHT); Label lb4 = new Label("Ellipse", new Ellipse(50, 50, 50, 25)); lb4.setContentDisplay(ContentDisplay.LEFT); Ellipse ellipse = new Ellipse(50, 50, 50, 25); ellipse.setStroke(Color.GREEN); ellipse.setFill(Color.WHITE); StackPane stackPane = new StackPane(); stackPane.getChildren().addAll(ellipse, new Label("JavaFX")); Label lb5 = new Label("A pane inside a label", stackPane); lb5.setContentDisplay(ContentDisplay.BOTTOM); HBox pane = new HBox(20); pane.getChildren().addAll(lb1, lb2, lb3, lb4, lb5); Scene scene = new Scene(pane, 700, 150); primaryStage.setTitle("LabelWithGraphic"); primaryStage.setScene(scene); primaryStage.show(); }
private void configureBackground() { ImageView imageView = new ImageView(); Image image = loadImage(); imageView.setImage(image); Circle circle1 = new Circle(); circle1.setCenterX(140); circle1.setCenterY(140); circle1.setRadius(120); circle1.setFill(Color.TRANSPARENT); circle1.setStroke(Color.web("#0A0A0A")); circle1.setStrokeWidth(0.3); Circle circle2 = new Circle(); circle2.setCenterX(140); circle2.setCenterY(140); circle2.setRadius(118); circle2.setFill(Color.TRANSPARENT); circle2.setStroke(Color.web("#0A0A0A")); circle2.setStrokeWidth(0.3); Circle circle3 = new Circle(); circle3.setCenterX(140); circle3.setCenterY(140); circle3.setRadius(140); circle3.setFill(Color.TRANSPARENT); circle3.setStroke(Color.web("#818a89")); circle3.setStrokeWidth(1); Ellipse ellipse = new Ellipse(140, 95, 180, 95); Circle ellipseClip = new Circle(140, 140, 140); ellipse.setFill(Color.web("#535450")); ellipse.setStrokeWidth(0); GaussianBlur ellipseEffect = new GaussianBlur(); ellipseEffect.setRadius(10); ellipse.setEffect(ellipseEffect); ellipse.setOpacity(0.1); ellipse.setClip(ellipseClip); background.getChildren().addAll(imageView, circle1, circle2, circle3, ellipse); }