API java : SpringLayout.Constraints


javax.swing
Class SpringLayout.Constraints

java.lang.Object
  extended by javax.swing.SpringLayout.Constraints
Enclosing class:
SpringLayout

public static class SpringLayout.Constraints
extends Object

A Constraints object holds the constraints that govern the way a component's size and position change in a container controlled by a SpringLayout. A Constraints object is like a Rectangle, in that it has x, y, width, and height properties. In the Constraints object, however, these properties have Spring values instead of integers. In addition, a Constraints object can be manipulated as four edges -- north, south, east, and west -- using the constraint property.

The following formulas are always true for a Constraints object:

  1. west = x
  2. north = y
  3. east = x + width
  4. south = y + height
Note: In this document, operators represent methods in the Spring class. For example, "a + b" is equal to Spring.sum(a, b), and "a - b" is equal to Spring.sum(a, Spring.minus(b)). See the Spring API documentation for further details of spring arithmetic.

Because a Constraints object's properties -- representing its edges, size, and location -- can all be set independently and yet are interrelated, the object can become over-constrained. For example, if both the x and width properties are set and then the east edge is set, the object is over-constrained horizontally. When this happens, one of the values (in this case, the x property) automatically changes so that the formulas still hold.

The following table shows which value changes when a Constraints object is over-constrained horizontally.

Value Being Set
(method used)
Result When Over-Constrained Horizontally
(x, width, and the east edge are all non-null)
x or the west edge
(setX or setConstraint)
width value is automatically set to east - x.
width
(setWidth)
east edge's value is automatically set to x + width.
east edge
(setConstraint)
x value is automatically set to east - width.

The rules for the vertical properties are similar:

Value Being Set
(method used)
Result When Over-Constrained Vertically
(y, height, and the south edge are all non-null)
y or the north edge
(setY or setConstraint)
height value is automatically set to south - y.
height
(setHeight)
south edge's value is automatically set to y + height.
south edge
(setConstraint)
y value is automatically set to south - height.


Constructor Summary
SpringLayout.Constraints()
          Creates an empty Constraints object.
SpringLayout.Constraints(Component c)
          Creates a Constraints object with suitable x, y, width and height springs for component, c.
SpringLayout.Constraints(Spring x, Spring y)
          Creates a Constraints object with the specified values for its x and y properties.
SpringLayout.Constraints(Spring x, Spring y, Spring width, Spring height)
          Creates a Constraints object with the specified values for its x, y, width, and height properties.
 
Method Summary
 Spring getConstraint(String edgeName)
          Returns the value of the specified edge.
 Spring getHeight()
          Returns the value of the height property.
 Spring getWidth()
          Returns the value of the width property.
 Spring getX()
          Returns the value of the x property.
 Spring getY()
          Returns the value of the y property.
 void setConstraint(String edgeName, Spring s)
          Sets the spring controlling the specified edge.
 void setHeight(Spring height)
          Sets the height property, which controls the height of a component.
 void setWidth(Spring width)
          Sets the width property, which controls the width of a component.
 void setX(Spring x)
          Sets the x property, which controls the x value of a component's location.
 void setY(Spring y)
          Sets the y property, which controls the y value of a component's location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringLayout.Constraints

public SpringLayout.Constraints()
Creates an empty Constraints object.


SpringLayout.Constraints

public SpringLayout.Constraints(Spring x,
                                Spring y)
Creates a Constraints object with the specified values for its x and y properties. The height and width springs have null values.

Parameters:
x - the spring controlling the component's x value
y - the spring controlling the component's y value

SpringLayout.Constraints

public SpringLayout.Constraints(Spring x,
                                Spring y,
                                Spring width,
                                Spring height)
Creates a Constraints object with the specified values for its x, y, width, and height properties. Note: If the SpringLayout class encounters null values in the Constraints object of a given component, it replaces them with suitable defaults.

Parameters:
x - the spring value for the x property
y - the spring value for the y property
width - the spring value for the width property
height - the spring value for the height property

SpringLayout.Constraints

public SpringLayout.Constraints(Component c)
Creates a Constraints object with suitable x, y, width and height springs for component, c. The x and y springs are constant springs initialised with the component's location at the time this method is called. The width and height springs are special springs, created by the Spring.width() and Spring.height() methods, which track the size characteristics of the component when they change.

Parameters:
c - the component whose characteristics will be reflected by this Constraints object
Throws:
NullPointerException - if c is null.
Since:
1.5
Method Detail

setX

public void setX(Spring x)
Sets the x property, which controls the x value of a component's location.

Parameters:
x - the spring controlling the x value of a component's location
See Also:
getX(), SpringLayout.Constraints

getX

public Spring getX()
Returns the value of the x property.

Returns:
the spring controlling the x value of a component's location
See Also:
setX(javax.swing.Spring), SpringLayout.Constraints

setY

public void setY(Spring y)
Sets the y property, which controls the y value of a component's location.

Parameters:
y - the spring controlling the y value of a component's location
See Also:
getY(), SpringLayout.Constraints

getY

public Spring getY()
Returns the value of the y property.

Returns:
the spring controlling the y value of a component's location
See Also:
setY(javax.swing.Spring), SpringLayout.Constraints

setWidth

public void setWidth(Spring width)
Sets the width property, which controls the width of a component.

Parameters:
width - the spring controlling the width of this Constraints object
See Also:
getWidth(), SpringLayout.Constraints

getWidth

public Spring getWidth()
Returns the value of the width property.

Returns:
the spring controlling the width of a component
See Also:
setWidth(javax.swing.Spring), SpringLayout.Constraints

setHeight

public void setHeight(Spring height)
Sets the height property, which controls the height of a component.

Parameters:
height - the spring controlling the height of this Constraints object
See Also:
getHeight(), SpringLayout.Constraints

getHeight

public Spring getHeight()
Returns the value of the height property.

Returns:
the spring controlling the height of a component
See Also:
setHeight(javax.swing.Spring), SpringLayout.Constraints

setConstraint

public void setConstraint(String edgeName,
                          Spring s)
Sets the spring controlling the specified edge. The edge must have one of the following values: SpringLayout.NORTH, SpringLayout.SOUTH, SpringLayout.EAST, SpringLayout.WEST.

Parameters:
edgeName - the edge to be set
s - the spring controlling the specified edge
See Also:
getConstraint(java.lang.String), SpringLayout.NORTH, SpringLayout.SOUTH, SpringLayout.EAST, SpringLayout.WEST, SpringLayout.Constraints

getConstraint

public Spring getConstraint(String edgeName)
Returns the value of the specified edge. The edge must have one of the following values: SpringLayout.NORTH, SpringLayout.SOUTH, SpringLayout.EAST, SpringLayout.WEST.

Parameters:
edgeName - the edge whose value is to be returned
Returns:
the spring controlling the specified edge
See Also:
setConstraint(java.lang.String, javax.swing.Spring), SpringLayout.NORTH, SpringLayout.SOUTH, SpringLayout.EAST, SpringLayout.WEST, SpringLayout.Constraints

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

8 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-2456
Document créé le 30/08/06 21:57, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-javax/swing/SpringLayout.Constraints.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,51 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Le destin n'est pas une chaîne mais un envol.

Alessandro Baricco
 
l'infobrol
Nous sommes le Samedi 02 Juin 2012, 04:47, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)