Home java javafx How to make a rounded object?

javafx How to make a rounded object?

Author

Date

Category

I want to make such an object, and put a blur on Gauss


Answer 1, Authority 100%

In order to round the corners from the rectangle, it is enough just to cause the appropriate class methods.

If you follow documentation , you can see that the parameters are responsible for the rounding:

ArcWidth – determines the horizontal diameter of the arc in four corners of the rectangle
Archeight – Determines the vertical diameter of the arc in four corners of the rectangle.

They can be installed via setArcwidth and setArcheight , respectively.

rectangle rect = new rectangle (110, 110, 200, 200);
Rect.SetarCwidth (20);
Rect.Setarchheight (20);
Rect.Setstroke (Color.green);
Rect.Setstrokewidth (10);

If canvas is used, then when drawing, you can specify these parameters immediately in the designer on the 5th and 6th parameters:

GraphicsContext GC = canvas.getgraphicscontext2d ();
GC.setFill (Color.RED);
GC.FillroundRect (50, 50, 100, 100, 30, 30);

Answer 2, Authority 100%

It is possible to use CSS : -fx-border-radius and -fx-border-insets

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions