Code: Select all
public class NewMain extends Application {
@Override
public void start(Stage primaryStage) {
var path = "M0,2 H8 V4 H0 Z M0,2 H1 V9 H0 Z M0,8 H8 V9 H0 Z M7,2 H8 V9 H7 Z";
var svgPath = new SVGPath();
svgPath.setContent(path);
var region = new Region();
region.setStyle("-fx-shape:\"" + path + "\";"
+ "-fx-scale-shape: false;"
+ "-fx-pref-width: 20px;"
+ "-fx-pref-height: 20px;"
+ "-fx-background-color: black");
var button = new Button(null, region);
VBox root = new VBox(svgPath, button);
root.setPadding(new Insets(20));
root.setSpacing(20);
Scene scene = new Scene(root, 100, 100);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
< /p>
Wie Sie sehen, wird SVGPath korrekt gerendert, das Symbol in der Taste (mit demselben SVG) ist jedoch verschwommen. Könnte jemand sagen, wie man es behebt?