The following example shows you how you can change the header height on a Panel container in Flex by setting the headerHeight style.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/12/setting-the-header-height-on-a-flex-panel-container/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:ApplicationControlBar dock="true">
<mx:Form styleName="plain">
<mx:FormItem label="headerHeight:">
<mx:HSlider id="slider"
minimum="24"
maximum="64"
value="32"
snapInterval="2"
tickInterval="4"
liveDragging="true" />
</mx:FormItem>
</mx:Form>
</mx:ApplicationControlBar>
<mx:Panel id="panel"
title="The quick brown fox jumped"
status="{panel.width}x{panel.height}"
titleIcon="@Embed('assets/Panel.png')"
headerHeight="{slider.value}"
borderColor="haloBlue"
borderAlpha="1.0"
width="400"
height="150">
<mx:VBox id="vBox" width="100%" height="100%">
<mx:Label text="{vBox.width}x{vBox.height}" />
</mx:VBox>
</mx:Panel>
</mx:Application>
View source is enabled in the following example.

{ 9 comments… read them below or add one }
Nice site. I’m happy to find it and am finding it useful.
The change in background color on this reply is nice too.
One thing I noticed is you are not separating your code. If you are going to teach people flex please teach them to use separate style sheets and follow best practices.
Thanks again! keep it up!
Alex
Alex,
No, I typically haven’t been separating code. I have on a few examples if I have a big data set (I may externalize the XML, for example).
Typically I leave it all in one code block so it is [hopefully] easier for people to copy/paste. Otherwise, they’ll have to right-click on the SWFs, select “View Source” and try and recreate the project piece by piece.
Peter
Hi, I’ve been working with flex for a couple of weeks now and i was looking for some way to put an image in the panel’s header just as you have on your example, i tried the same code
titleIcon="@Embed('assets/Panel.png')"with of course the name of my file and the folder where it’s contained (this folder is contained in the main project folder). But it still doesn’t work, is there a specific location where the file must be or am I missing something??
Antonio,
That code should work. If you are using Flex Builder 3, you should have the have the PNG file in the /src/assets/ folder, and your MXML file should be in the /src/ file.
You can download the project source code above and view the directory structure and probably try importing the project into Flex Builder.
Peter
Hey Folks,
I see a dark line between header and body of my panel. I have set the border thickness to be zero from all sides. Is there any way to remove that?
I have a list box inside the panel. I have an requirement to specify the height of the panel as the length of the data source which I gave for the list box.
Ganesh,
I’d try creating a Panel and not specifying a height, that way the Panel container should size based on it’s children’s dimensions. Next, bind the nested List control’s
rowCountproperty to the number of items in the List control’s data provider. That way, the List should always resize itself to the display all of its items (which may or may not look terrible, considering how many items you have in the List dataProvider).Peter
Should headerHeight work in Gumbo? It does not for me.
The titlebar title is pushed down by a gray area’s height on a top is not changed.
Mark,
It should, but I believe there is currently an open bug on the issue: [SDK-21549] “Halo Panel
headerHeightstyle does not function as expected with Spark Skin”.Peter