简体   繁体   中英

How can I make a ring in JavaFX (fxml)

I need to make a ring in JavaFX using fxml. It will be circling an item on an image beneath it. I can make a circle, but it seems to be required to have a fill. I can adjust the opacity, but that adjusts the opacity of both the fill and the circle.

I don't have image editing software at work (and I can't just install gimp) so I can't create an image and use an ImageView. Paint won't let you save images without backgrounds.

It seems like such a simple task to create a circle without a fill. Am I missing something?

Thanks

You can use the circle for that, just make sure to add this in your CSS:

 .circle {
 /* The numbers before the alpha doesn't matter.  
    As you imagine this would be green if the alpha was higher
    rgba(RED,GREEN,BLUE,ALPHA); RGBA
 */ 
         -fx-fill:  rgba(0,255,0,0);

 }

if you want to have other circles you can specify an specific css class for this:

 .ring {
      -fx-fill:  rgba(0,255,0,0);
 }

Then:

circle.getStyleClass().add("ring");

您可以使用color.TRANSPARENT填充和所需颜色的笔触。

或者,按照与Mansueli相同的想法,以编程方式使用此方法:

circle.setFill(new Color(0,0,0,0));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM