简体   繁体   English

JavaFX-自定义按钮形状

[英]JavaFX - Customized Button Shape

I want a Button to look like below shape in JavaFX , 我希望ButtonJavaFX中看起来像下面的形状,

在此处输入图片说明

with, -fx-background-radius: 20; 带有-fx-background-radius: 20; i am able to achieve the corner radius . 我能够达到拐角半径。

How should i proceed further to get the above shaped Button . 我应该如何进一步获得上述形状的Button

You need to use the -fx-shape property. 您需要使用-fx-shape属性。

You can find it in Oracle's reference guide: https://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#references 您可以在Oracle参考指南中找到它: https : //docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#references

This is is also useful to understand how to draw the "path" associated with your shape: https://www.w3.org/TR/SVG/paths.html 这对于了解如何绘制与形状关联的“路径”也很有用: https : //www.w3.org/TR/SVG/paths.html

You may want to use an SVG editor for your shape's path; 您可能要使用SVG编辑器作为形状的路径。 for example: https://github.com/SVG-Edit/svgedit 例如: https//github.com/SVG-Edit/svgedit

something like this should do the trick; 这样的事情应该可以解决问题; you should need to add the curves -fx-shape: "M50 100 L150 100 L180 250 L20 250 Z"; 您应该添加曲线-fx-shape:“ M50 100 L150 100 L180 250 L20 250 Z”;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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