Flex - Panneau

introduction

La classe Panel est un conteneur qui comprend une barre de titre, une légende, une bordure et une zone de contenu pour ses enfants.

Déclaration de classe

Voici la déclaration pour spark.components.Panel classe -

public class Panel
   extends SkinnableContainer

Propriétés publiques

Sr.Non Propriété et description
1

controlBarContent : Array

Ensemble de composants à inclure dans la zone de la barre de contrôle du conteneur Panel.

2

controlBarLayout : LayoutBase

Définit la disposition de la zone de la barre de contrôle du conteneur.

3

controlBarVisible : Boolean

Si vrai, la barre de contrôle est visible.

4

title : String

Titre ou légende affiché dans la barre de titre.

Méthodes publiques

Sr.Non Méthode et description
1

Panel()

Constructeur.

Méthodes héritées

Cette classe hérite des méthodes des classes suivantes -

  • 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

Exemple de panneau Flex

Suivons les étapes suivantes pour vérifier l'utilisation de Panel dans une application Flex en créant une application de test -

Étape La description
1 Créez un projet avec un nom HelloWorld sous un package com.tutorialspoint.client comme expliqué dans le chapitre Flex - Créer une application .
2 Modifiez HelloWorld.mxml comme expliqué ci-dessous. Gardez le reste des fichiers inchangé.
3 Compilez et exécutez l'application pour vous assurer que la logique métier fonctionne conformément aux exigences.

Voici le contenu du fichier mxml modifié 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>

Une fois que vous êtes prêt avec tous les changements effectués, laissez-nous compiler et exécuter l'application en mode normal comme nous l'avons fait dans le chapitre Flex - Créer une application . Si tout va bien avec votre application, elle produira le résultat suivant: [ Essayez-le en ligne ]