如何使用 JavaFX 创建一个通知气泡,类似于 iPhone 菜单上的通知标记?
How can I create a notification bubble, similar to the notification badge on iPhones' menus, using JavaFX?
我是 JavaFX 的新手,我正在尝试创建类似于下图的通知标志。
它将用作通知计数,我希望将它放在 JavaFX 按钮的角上。我的问题是我找不到支持这个的本机解决方案。谁能推荐一种方法?
谢谢
是这样的吗?也许不是很漂亮(我不是艺术家),但我认为它可能涵盖了解决方案。
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="${button.prefHeight}" prefWidth="${button.prefWidth}" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Button fx:id="button" layoutY="8.0" mnemonicParsing="false" text="Click " AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
<StackPane layoutX="57.0" layoutY="-13.0" AnchorPane.rightAnchor="-10" AnchorPane.topAnchor="-10">
<children>
<Circle radius="10.0" stroke="BLACK" strokeType="INSIDE">
<fill>
<RadialGradient centerX="0.5" centerY="0.5" radius="0.8164556962025317">
<stops>
<Stop color="#ff361beb" />
<Stop color="WHITE" offset="1.0" />
</stops>
</RadialGradient>
</fill>
</Circle>
<Label text="5" />
</children>
</StackPane>
</children>
</AnchorPane>
我是 JavaFX 的新手,我正在尝试创建类似于下图的通知标志。
它将用作通知计数,我希望将它放在 JavaFX 按钮的角上。我的问题是我找不到支持这个的本机解决方案。谁能推荐一种方法?
谢谢
是这样的吗?也许不是很漂亮(我不是艺术家),但我认为它可能涵盖了解决方案。
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="${button.prefHeight}" prefWidth="${button.prefWidth}" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Button fx:id="button" layoutY="8.0" mnemonicParsing="false" text="Click " AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
<StackPane layoutX="57.0" layoutY="-13.0" AnchorPane.rightAnchor="-10" AnchorPane.topAnchor="-10">
<children>
<Circle radius="10.0" stroke="BLACK" strokeType="INSIDE">
<fill>
<RadialGradient centerX="0.5" centerY="0.5" radius="0.8164556962025317">
<stops>
<Stop color="#ff361beb" />
<Stop color="WHITE" offset="1.0" />
</stops>
</RadialGradient>
</fill>
</Circle>
<Label text="5" />
</children>
</StackPane>
</children>
</AnchorPane>