java.lang.Objectjavax.swing.SizeRequirements
public class SizeRequirements
For the convenience of layout managers, calculates information about the size and position of components. All size and position calculation methods are class methods that take arrays of SizeRequirements as arguments. The SizeRequirements class supports two types of layout:
- tiled
- The components are placed end-to-end, starting either at coordinate 0 (the leftmost or topmost position) or at the coordinate representing the end of the allocated span (the rightmost or bottommost position).
- aligned
- The components are aligned as specified by each component's X or Y alignment value.
Each SizeRequirements object contains information about either the width (and X alignment) or height (and Y alignment) of a single component or a group of components:
minimum- The smallest reasonable width/height of the component or component group, in pixels.
preferred- The natural width/height of the component or component group, in pixels.
maximum- The largest reasonable width/height of the component or component group, in pixels.
alignment- The X/Y alignment of the component or component group.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder.
Component.getMinimumSize(),
Component.getPreferredSize(),
Component.getMaximumSize(),
Component.getAlignmentX(),
Component.getAlignmentY()| Field Summary | |
|---|---|
float |
alignment
The alignment, specified as a value between 0.0 and 1.0, inclusive. |
int |
maximum
The maximum size allowed. |
int |
minimum
The minimum size required. |
int |
preferred
The preferred (natural) size. |
| Constructor Summary | |
|---|---|
SizeRequirements()
Creates a SizeRequirements object with the minimum, preferred, and maximum sizes set to zero and an alignment value of 0.5 (centered). |
|
SizeRequirements(int min,
int pref,
int max,
float a)
Creates a SizeRequirements object with the specified minimum, preferred, and maximum sizes and the specified alignment. |
|
| Method Summary | |
|---|---|
static int[] |
adjustSizes(int delta,
SizeRequirements[] children)
Adjust a specified array of sizes by a given amount. |
static void |
calculateAlignedPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans)
Creates a bunch of offset/span pairs specifying how to lay out a set of components with the specified alignments. |
static void |
calculateAlignedPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans,
boolean normal)
Creates a set of offset/span pairs specifying how to lay out a set of components with the specified alignments. |
static void |
calculateTiledPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans)
Creates a set of offset/span pairs representing how to lay out a set of components end-to-end. |
static void |
calculateTiledPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans,
boolean forward)
Creates a set of offset/span pairs representing how to lay out a set of components end-to-end. |
static SizeRequirements |
getAlignedSizeRequirements(SizeRequirements[] children)
Determines the total space necessary to align a set of components. |
static SizeRequirements |
getTiledSizeRequirements(SizeRequirements[] children)
Determines the total space necessary to place a set of components end-to-end. |
String |
toString()
Returns a string describing the minimum, preferred, and maximum size requirements, along with the alignment. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public int minimum
comp, this should be equal to either
comp.getMinimumSize().width or
comp.getMinimumSize().height.
public int preferred
comp, this should be equal to either
comp.getPreferredSize().width or
comp.getPreferredSize().height.
public int maximum
comp, this should be equal to either
comp.getMaximumSize().width or
comp.getMaximumSize().height.
public float alignment
| Constructor Detail |
|---|
public SizeRequirements()
public SizeRequirements(int min,
int pref,
int max,
float a)
min - the minimum size >= 0pref - the preferred size >= 0max - the maximum size >= 0a - the alignment >= 0.0f && <= 1.0f| Method Detail |
|---|
public String toString()
public static SizeRequirements getTiledSizeRequirements(SizeRequirements[] children)
children - the space requirements for a set of components.
The vector may be of zero length, which will result in a
default SizeRequirements object instance being passed back.
public static SizeRequirements getAlignedSizeRequirements(SizeRequirements[] children)
children - the set of child requirements. If of zero length,
the returns result will be a default instance of SizeRequirements.
public static void calculateTiledPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans)
allocated - the total span to be allocated >= 0.total - the total of the children requests. This argument
is optional and may be null.children - the size requirements for each component.offsets - the offset from 0 for each child where
the spans were allocated (determines placement of the span).spans - the span allocated for each child to make the
total target span.
public static void calculateTiledPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans,
boolean forward)
allocated - the total span to be allocated >= 0.total - the total of the children requests. This argument
is optional and may be null.children - the size requirements for each component.offsets - the offset from 0 for each child where
the spans were allocated (determines placement of the span).spans - the span allocated for each child to make the
total target span.forward - tile with offsets increasing from 0 if true
and with offsets decreasing from the end of the allocated space
if false.
public static void calculateAlignedPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans)
allocated - the total span to be allocated >= 0.total - the total of the children requests.children - the size requirements for each component.offsets - the offset from 0 for each child where
the spans were allocated (determines placement of the span).spans - the span allocated for each child to make the
total target span.
public static void calculateAlignedPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans,
boolean normal)
allocated - the total span to be allocated >= 0.total - the total of the children requests.children - the size requirements for each component.offsets - the offset from 0 for each child where
the spans were allocated (determines placement of the span).spans - the span allocated for each child to make the
total target span.normal - when true, the alignment value 0.0f means
left/top; when false, it means right/bottom.
public static int[] adjustSizes(int delta,
SizeRequirements[] children)
delta - an int specifying the size differencechildren - an array of SizeRequirements objects
Ces informations proviennent du site de http://java.sun.com
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 :
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.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
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.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)