2 Replies Latest reply on Nov 26, 2009 12:30 PM by laxmidi

    How can I make a Panel's Title Wordwrap?

    laxmidi Level 1

      Is there a way to make a panel's title be multiline? I've got a panel where the title is dynamic. I don't know how long the title will be. As it works now, the the title occaisionally gets cut-off. Is there a way to wordwrap a panel's title?


      <mx:Panel id="mySchoolPanel" " 



               x="710" y="150"

               headerHeight="50" >


      Thank you.



        • 1. Re: How can I make a Panel's Title Wordwrap?
          paul.williams Level 4

          The layout logic of Panel appears to assume a single line of text in the title, so to get word-wrapping you may need to extend the class. I had a go at it below - will probably need some tweaking:


              import mx.containers.Panel;

              public class WrappingPanel extends Panel
                  // Hard coded padding above and below title text. Should be broken-out
                  // into a style.
                  private static const HEADER_PADDING : int = 6;
                  protected override function createChildren():void
                      titleTextField.wordWrap = true;
                  protected override function getHeaderHeight():Number
                      // Set the header height dynamically based on the height of the title
                      return titleTextField.measuredHeight + HEADER_PADDING * 2;
                  protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                      super.updateDisplayList( unscaledWidth, unscaledHeight );
                      // Set the height of the title to fit all text
                      titleTextField.height = titleTextField.measuredHeight;
                      // Position the title
                      titleTextField.y = HEADER_PADDING;

          • 2. Re: How can I make a Panel's Title Wordwrap?
            laxmidi Level 1

            Hi Paul,


            Thank you so much for the answer. I never would have come up with that.