API java : CardLayout


java.awt
Class CardLayout

java.lang.Object
  extended by java.awt.CardLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2, Serializable

public class CardLayout
extends Object
implements LayoutManager2, Serializable

A CardLayout object is a layout manager for a container. It treats each component in the container as a card. Only one card is visible at a time, and the container acts as a stack of cards. The first component added to a CardLayout object is the visible component when the container is first displayed.

The ordering of cards is determined by the container's own internal ordering of its component objects. CardLayout defines a set of methods that allow an application to flip through these cards sequentially, or to show a specified card. The addLayoutComponent(java.awt.Component, java.lang.Object) method can be used to associate a string identifier with a given card for fast random access.

Since:
JDK1.0
See Also:
Container, Serialized Form

Constructor Summary
CardLayout()
          Creates a new card layout with gaps of size zero.
CardLayout(int hgap, int vgap)
          Creates a new card layout with the specified horizontal and vertical gaps.
 
Method Summary
 void addLayoutComponent(Component comp, Object constraints)
          Adds the specified component to this card layout's internal table of names.
 void addLayoutComponent(String name, Component comp)
          Deprecated. replaced by addLayoutComponent(Component, Object).
 void first(Container parent)
          Flips to the first card of the container.
 int getHgap()
          Gets the horizontal gap between components.
 float getLayoutAlignmentX(Container parent)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(Container parent)
          Returns the alignment along the y axis.
 int getVgap()
          Gets the vertical gap between components.
 void invalidateLayout(Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void last(Container parent)
          Flips to the last card of the container.
 void layoutContainer(Container parent)
          Lays out the specified container using this card layout.
 Dimension maximumLayoutSize(Container target)
          Returns the maximum dimensions for this layout given the components in the specified target container.
 Dimension minimumLayoutSize(Container parent)
          Calculates the minimum size for the specified panel.
 void next(Container parent)
          Flips to the next card of the specified container.
 Dimension preferredLayoutSize(Container parent)
          Determines the preferred size of the container argument using this card layout.
 void previous(Container parent)
          Flips to the previous card of the specified container.
 void removeLayoutComponent(Component comp)
          Removes the specified component from the layout.
 void setHgap(int hgap)
          Sets the horizontal gap between components.
 void setVgap(int vgap)
          Sets the vertical gap between components.
 void show(Container parent, String name)
          Flips to the component that was added to this layout with the specified name, using addLayoutComponent.
 String toString()
          Returns a string representation of the state of this card layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CardLayout

public CardLayout()
Creates a new card layout with gaps of size zero.


CardLayout

public CardLayout(int hgap,
                  int vgap)
Creates a new card layout with the specified horizontal and vertical gaps. The horizontal gaps are placed at the left and right edges. The vertical gaps are placed at the top and bottom edges.

Parameters:
hgap - the horizontal gap.
vgap - the vertical gap.
Method Detail

getHgap

public int getHgap()
Gets the horizontal gap between components.

Returns:
the horizontal gap between components.
Since:
JDK1.1
See Also:
setHgap(int), getVgap()

setHgap

public void setHgap(int hgap)
Sets the horizontal gap between components.

Parameters:
hgap - the horizontal gap between components.
Since:
JDK1.1
See Also:
getHgap(), setVgap(int)

getVgap

public int getVgap()
Gets the vertical gap between components.

Returns:
the vertical gap between components.
See Also:
setVgap(int), getHgap()

setVgap

public void setVgap(int vgap)
Sets the vertical gap between components.

Parameters:
vgap - the vertical gap between components.
Since:
JDK1.1
See Also:
getVgap(), setHgap(int)

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constraints)
Adds the specified component to this card layout's internal table of names. The object specified by constraints must be a string. The card layout stores this string as a key-value pair that can be used for random access to a particular card. By calling the show method, an application can display the component with the specified name.

Specified by:
addLayoutComponent in interface LayoutManager2
Parameters:
comp - the component to be added.
constraints - a tag that identifies a particular card in the layout.
Throws:
IllegalArgumentException - if the constraint is not a string.
See Also:
show(java.awt.Container, java.lang.String)

addLayoutComponent

@Deprecated
public void addLayoutComponent(String name,
                                          Component comp)
Deprecated. replaced by addLayoutComponent(Component, Object).

Description copied from interface: LayoutManager
If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the string to be associated with the component
comp - the component to be added

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
comp - the component to be removed.
See Also:
Container.remove(java.awt.Component), Container.removeAll()

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Determines the preferred size of the container argument using this card layout.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - the parent container in which to do the layout
Returns:
the preferred dimensions to lay out the subcomponents of the specified container
See Also:
Container.getPreferredSize(), minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Calculates the minimum size for the specified panel.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - the parent container in which to do the layout
Returns:
the minimum dimensions required to lay out the subcomponents of the specified container
See Also:
Container.doLayout(), preferredLayoutSize(java.awt.Container)

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)
Returns the maximum dimensions for this layout given the components in the specified target container.

Specified by:
maximumLayoutSize in interface LayoutManager2
Parameters:
target - the component which needs to be laid out
See Also:
Container, minimumLayoutSize(java.awt.Container), preferredLayoutSize(java.awt.Container)

getLayoutAlignmentX

public float getLayoutAlignmentX(Container parent)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentX in interface LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(Container parent)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentY in interface LayoutManager2

invalidateLayout

public void invalidateLayout(Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface LayoutManager2

layoutContainer

public void layoutContainer(Container parent)
Lays out the specified container using this card layout.

Each component in the parent container is reshaped to be the size of the container, minus space for surrounding insets, horizontal gaps, and vertical gaps.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - the parent container in which to do the layout
See Also:
Container.doLayout()

first

public void first(Container parent)
Flips to the first card of the container.

Parameters:
parent - the parent container in which to do the layout
See Also:
last(java.awt.Container)

next

public void next(Container parent)
Flips to the next card of the specified container. If the currently visible card is the last one, this method flips to the first card in the layout.

Parameters:
parent - the parent container in which to do the layout
See Also:
previous(java.awt.Container)

previous

public void previous(Container parent)
Flips to the previous card of the specified container. If the currently visible card is the first one, this method flips to the last card in the layout.

Parameters:
parent - the parent container in which to do the layout
See Also:
next(java.awt.Container)

last

public void last(Container parent)
Flips to the last card of the container.

Parameters:
parent - the parent container in which to do the layout
See Also:
first(java.awt.Container)

show

public void show(Container parent,
                 String name)
Flips to the component that was added to this layout with the specified name, using addLayoutComponent. If no such component exists, then nothing happens.

Parameters:
parent - the parent container in which to do the layout
name - the component name
See Also:
addLayoutComponent(java.awt.Component, java.lang.Object)

toString

public String toString()
Returns a string representation of the state of this card layout.

Overrides:
toString in class Object
Returns:
a string representation of this card layout.

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

6 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-1186
Document créé le 29/08/06 03:45, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/awt/CardLayout.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,76 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Ce qui est terrible sur cette terre, c'est que tout le monde a ses raisons.

Jean Renoir [Extrait du film La règle du jeu]
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 11:44, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)