Share on Google+Share on Google+

CheckBox in Flex

Advertisement
In this tutorial you will come to know about the CheckBox control of Flex. The CheckBox control of Flex is a very common GUI, which is supported by almost every computer language. CheckBox control is used when we need to have a set of true or false values. The examples will help you to learn CheckBox more effectively

Flex CheckBox Control:

The CheckBox control of Flex is a very common GUI, which is supported by almost every computer language. CheckBox control is used when we need to have a set of true or false values.

We can add a text label at left, right, top, bottom of a CheckBox. Flex automatically adjusts the label of the CheckBox control to fit in the component.

The default state of the CheckBox is unchecked, we can change the state of a CheckBox by selecting a particular CheckBox item.

<mx:CheckBox> tag is use to access this control. Like any other control we can specify an id to it for accessing from any other part of the file or from the ActionScript file.

Flex Checkbox Control Example:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Panel title="Example of CheckBox" horizontalCenter="10" verticalCenter="16" width="200" height="200">

<mx:VBox height="100%" width="100%">

<mx:CheckBox id="adobe" label="Adobe" click="chkValDisp()"/>

<mx:CheckBox id="sun" label="Sun" click="chkValDisp()" />

<mx:CheckBox id="mozilla" label="mozilla" click="chkValDisp()"/>

<mx:TextArea id="disp" height="75" width="100%"/>

</mx:VBox>

</mx:Panel>

<mx:Script>

<![CDATA[

import mx.events.ItemClickEvent;

public function chkValDisp():void{

disp.text="";

if(adobe.selected==true){

disp.text+="Flex"+"\n";

}

if(sun.selected==true){

disp.text+="JavaFx"+"\n";

}

if(mozilla.selected==true){

disp.text+="XUL"+"\n";

}

}

]]>

</mx:Script>

</mx:Application>

 

Output:

 

Advertisements

Advertisement

Posted on: January 27, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.