java - 鼠标单击填充上的 AnchorPane
问题描述
有什么方法可以制作AnchorPane
包含按钮,并且Text
在像按钮一样单击它时很少做填充?我正在使用 JavaFX 和 CSS,这是我的代码。一切正常,但没有填充
FXML
<AnchorPane id="pane" fx:id="pane" layoutX="65.0" layoutY="68.0" prefHeight="90.0" prefWidth="309.0" onMouseClicked="#onSickleButtonClicked" stylesheets="@style.css">
<children>
<Text fx:id="sickleLevelLabel" layoutX="193.0" layoutY="27.0" strokeType="OUTSIDE" strokeWidth="0.0" text="1" wrappingWidth="95.13671875">
<font>
<Font size="24.0" />
</font>
</Text>
<Button id="sickleButton" fx:id="sickleButton" disable="true" ellipsisString="" mnemonicParsing="false" opacity="0.0" prefHeight="76.0" prefWidth="298.0" visible="false">
</Button>
<Text fx:id="sickleUpCostLabel" layoutX="129.0" layoutY="66.0" strokeType="OUTSIDE" strokeWidth="0.0" text="10" wrappingWidth="60.136717826128006">
<font>
<Font size="20.0" />
</font>
</Text>
<Text fx:id="sickleIncomeLabel" layoutX="237.0" layoutY="66.0" strokeType="OUTSIDE" strokeWidth="0.0" text="2" wrappingWidth="51.749999821186066">
<font>
<Font size="20.0" />
</font>
</Text>
</children>
</AnchorPane>
CSS
#pane{
-fx-background-image: url(../Resources/sicklebutton.png);
-fx-background-size: 300 80;
-fx-background-repeat: no-repeat;
-fx-background-color: rgba(0,0,0,0);
}
#pane:hover{
-fx-effect:dropshadow(gaussian, rgba(0, 8, 29, 1), 10, 0, 0, 0);
-fx-cursor: hand;
}
#pane:pressed{
-fx-effect:dropshadow(gaussian, rgba(0, 8, 29, 1), 30, 0, 0, 0);
-fx-padding: 5,5,5,5;
}
#pane:disabled {
-fx-opacity: 0.6;
}
解决方案
推荐阅读
- shell - 从 Shell 脚本中的另一个目录运行 SQL 脚本
- java - 将项目转换为 Maven 后的外部化字符串问题
- jenkins - Jenkins - 检查特定作业是否正在使用 hudson 类运行
- javascript - DataTables 初始化多个子表且 columnDefs 完整
- ffmpeg - 使用ffmpeg从没有鼠标指针的视频中提取帧
- stripe-payments - Webhook 调用延迟发生。如何在用户单击付款按钮时使 Webhook 调用在后端运行
- unit-testing - 检查 Grails 上的调用静态方法
- angular - 工具提示不适用于 Angular Material 2.0.0-alpha.9-3 和 Angular 2?
- ubuntu - opnsips start 给出“ERROR:core:main_loop: failed to fork module processes”并退出
- angular - 以角度更改焦点上的输入类型