CheckBox組件表示一個復選框和一個可選的標簽。當用戶單擊CheckBox組件或其文本時,CheckBox組件將其選中的屬性設置為true以進行檢查,對于未選中的屬性將其設置為false。
以下是 spark.components.CheckBox 類的聲明:
public class CheckBox extends ToggleButtonBase
S.N. | 方法和描述 |
---|---|
1 | CheckBox() 構造函數(shù)。 |
此類繼承以下類中的方法:
spark.components.supportClasses.ToggleButtonBase
spark.components.supportClasses.ButtonBase
spark.components.supportClasses.SkinnableComponent
mx.core.UIComponent
mx.core.FlexSprite
flash.display.Sprite
flash.display.DisplayObjectContainer
flash.display.InteractiveObject
flash.display.DisplayObject
flash.events.EventDispatcher
Object
讓我們按照以下步驟通過創(chuàng)建測試應用程序來檢查Flex應用程序中CheckBox控件的使用:
步驟 | 描述 |
---|---|
1 | 在 Flex - 創(chuàng)建應用程序章節(jié)中所述,在包 com.tutorialspoint.client 下創(chuàng)建名為 HelloWorld 的項目。 |
2 | 修改 HelloWorld.mxml ,如下所述。 保持文件的其余部分不變。 |
3 | 編譯并運行應用程序,以確保業(yè)務邏輯按照要求工作。 |
以下是修改后的mxml文件 src / com.tutorialspoint / HelloWorld.mxml 的內容。
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" minWidth="500" minHeight="500" > <fx:Style source="/com/tutorialspoint/client/Style.css"/> <s:BorderContainer width="550" height="400" id="mainContainer" styleName="container"> <s:VGroup width="100%" height="100%" gap="50" horizontalAlign="center" verticalAlign="middle"> <s:Label id="lblHeader" text="Form Controls Demonstration" fontSize="40" color="0x777777" styleName="heading"/> <s:Panel id="checkBoxPanel" title="Using CheckBox" width="420" height="200" > <s:layout> <s:VerticalLayout gap="10" verticalAlign="middle" horizontalAlign="center"/> </s:layout> <s:CheckBox id="chkBox" label="Checked by default" selected="true" width="50%"/> <s:CheckBox id="chkBox1" label="Checked,Disabled" selected="true" enabled="false" width="50%"/> <s:CheckBox id="chkBox2" label="UnChecked" width="50%"/> <s:CheckBox id="chkBox3" label="UnChecked,Disabled" enabled="false" width="50%"/> </s:Panel > </s:VGroup> </s:BorderContainer> </s:Application>
準備好所有更改后,讓我們以正常模式編譯和運行應用程序,就像在 Flex - 創(chuàng)建應用程序中一樣 章節(jié)。 如果一切順利,您的應用程序,這將產生以下結果:[在線試用]
更多建議: