Share on Google+Share on Google+

ButtonBar in Flex4

Advertisement
The ButtonBar Control is comprises from the components of both the MX and the Spark and defines a horizontal group of logically allied buttons with a familiar look and navigation.

ButtonBar in Flex4:

The ButtonBar Control is comprises from the components of both the MX and the Spark and defines a horizontal group of logically allied buttons with a familiar look and navigation. On the basis of the value of the dataProvider?s property, the ButtonBar controls creates ButtonBar Control.The ButtonBar control defines a group of variant state buttons that changes its appearance on selection, e.g. When ButtonBar Control is pushed, the button the button changes its appearance to the selected state. while on release it returns to the deselected mode.

The ButtonBar control is used to addItem() and removeItem() to manipulate the dataProvider property to add and remove data items. It automatically adds or removes the necessary children based on changes to the dataProvider property.

Example:

<?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" viewSourceURL="srcview/index.html">

<fx:Script>

<![CDATA[

import spark.events.IndexChangeEvent;

protected function indexChangeHandler(event:IndexChangeEvent):void{

myTextArea.text = "";

myTextArea.text = myTextArea.text + "\nButton Bar label clicked = " + myButtonBar.selectedItem;

}

]]>

</fx:Script>

<s:Panel title="ButtonBar Sample" color="#990000" width="300" height="215">

<s:HGroup left="5" top="5" width="100%" height="100%">

<s:VGroup left="10" top="5" color="0x000000" horizontalAlign="center">

<s:ButtonBar id="myButtonBar" change="indexChangeHandler(event)">

<mx:ArrayCollection>

<fx:String>One</fx:String>

<fx:String>Two</fx:String>

<fx:String>Three</fx:String>

<fx:String>Four</fx:String>

</mx:ArrayCollection>

</s:ButtonBar>

<s:TextArea id="myTextArea" width="{myButtonBar.width}" height="137"/>

</s:VGroup>

</s:HGroup>

</s:Panel>

</s:Application>

 

Output:


Running Example:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Advertisements

Advertisement

Posted on: April 21, 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.