Flex 面板



介紹

Panel 類是一個容器,它包含標題欄、標題、邊框以及子元素的內容區域。

類宣告

以下是spark.components.Panel類的宣告:

public class Panel
   extends SkinnableContainer

公共屬性

序號 屬性和描述
1

controlBarContent : Array

要包含在 Panel 容器的控制欄區域中的元件集。

2

controlBarLayout : LayoutBase

定義容器控制欄區域的佈局。

3

controlBarVisible : Boolean

如果為 true,則控制欄可見。

4

title : String

在標題欄中顯示的標題或字幕。

公共方法

序號 方法和描述
1

Panel()

建構函式。

繼承的方法

此類繼承自以下類的方法:

  • spark.components.SkinnableContainer
  • spark.components.supportClasses.SkinnableContainerBase
  • 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

Flex Panel 示例

讓我們按照以下步驟檢查在 Flex 應用程式中 Panel 的用法,方法是建立一個測試應用程式:

步驟 描述
1 建立一個名為HelloWorld的專案,位於com.tutorialspoint.client包下,如Flex - 建立應用程式章節中所述。
2 修改HelloWorld.mxml,如下所述。保持其餘檔案不變。
3 編譯並執行應用程式,以確保業務邏輯按要求工作。

以下是修改後的 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 = "630" height = "480" id = "mainContainer"
      styleName = "container">
      <s:VGroup width = "100%" height = "100%" gap = "50"
         horizontalAlign = "center" verticalAlign = "middle">
         <s:Label id = "lblHeader" text = "Layout Panels Demonstration"
            fontSize = "40" color = "0x777777" styleName = "heading" />

         <s:Panel id = "panelPanel" title = "Using Panel" width = "500"
            height = "300">
            <s:layout>
               <s:HorizontalLayout  gap = "10"
                  verticalAlign = "middle" horizontalAlign = "center" />
            </s:layout>

            <s:Panel title = "Basic Layout Panel" top = "0"
               left = "5" height = "200" width = "150" >
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "0" />
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "55" />
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "110" />
            </s:Panel>

            <s:Panel title = "Horizontal Layout Panel" top = "0"
               left = "5" height = "200" width = "170" >
               <s:layout>
                  <s:HorizontalLayout/>
               </s:layout>
               
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "0" />
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "55" />
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "110" />
            </s:Panel>
            
            <s:Panel title = "Vertical Layout Panel" top = "0"
               left = "5" height = "200" width = "150" >
               <s:layout>
                  <s:VerticalLayout />
               </s:layout>
               
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "0" />
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "55" />
               <s:BorderContainer width = "50" height = "50"
                  borderWeight = "2" color = "0x323232" top = "110" />
            </s:Panel>
         </s:Panel>
      </s:VGroup>
   </s:BorderContainer>
</s:Application>

完成所有更改後,讓我們像在Flex - 建立應用程式章節中那樣,在普通模式下編譯並執行應用程式。如果應用程式一切正常,它將產生以下結果:[線上試用]

Flex Panel
flex_layout_panels.htm
廣告
© . All rights reserved.