1. 程式人生 > 其它 >JFoenix中文教程:2、JFXButton按鈕元件

JFoenix中文教程:2、JFXButton按鈕元件

技術標籤:JFoenix中文教程javafxjava

JFoenix提供的按鈕元件為JFXButton,JFXButton提供了兩種按鈕形式:FLAT、RAISED,預設是 FLAT。

首先,先看一組按鈕效果:

JFXButton效果

對應原始碼如下:

<JFXButton layoutX="50" layoutY="40" prefWidth="200" prefHeight="50" buttonType="FLAT" text="FLAT 按鈕 無底色" style="-fx-font-size: 14px;"/>

<JFXButton layoutX="300" layoutY="40" prefWidth="200" prefHeight="50" buttonType="FLAT" text="FLAT 按鈕 有底色" style="-fx-font-size: 14px; -fx-background-color: #F4A460;"/>

<JFXButton layoutX="550" layoutY="40" prefWidth="200" prefHeight="50" buttonType="FLAT" text="FLAT 按鈕 禁用" style="-fx-font-size: 14px; -fx-background-color: #F4A460;" disable="true"/>

<JFXButton layoutX="50" layoutY="120" prefWidth="200" prefHeight="50" buttonType="RAISED" text="RAISED 按鈕 無底色" style="-fx-font-size: 14px;"/>

<JFXButton layoutX="300" layoutY="120" prefWidth="200" prefHeight="50" buttonType="RAISED" text="RAISED 按鈕 有底色" style="-fx-font-size: 14px; -fx-background-color: #F4A460;"/>

<JFXButton layoutX="550" layoutY="120" prefWidth="200" prefHeight="50" buttonType="RAISED" text="RAISED 按鈕 禁用" style="-fx-font-size: 14px; -fx-background-color: #F4A460;" disable="true"/>

以上,可以看出,FLAT 屬性是常規按鈕,RAISED 是一種帶有陰影效果的按鈕樣式,兩者在點選時均有動態效果。