API java : TreePath


javax.swing.tree
Class TreePath

java.lang.Object
  extended by javax.swing.tree.TreePath
All Implemented Interfaces:
Serializable

public class TreePath
extends Object
implements Serializable

Represents a path to a node. A TreePath is an array of Objects that are vended from a TreeModel. The elements of the array are ordered such that the root is always the first element (index 0) of the array. TreePath is Serializable, but if any components of the path are not serializable, it will not be written out.

For further information and examples of using tree paths, see How to Use Trees in The Java Tutorial.

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.


Constructor Summary
protected TreePath()
          Primarily provided for subclasses that represent paths in a different manner.
  TreePath(Object singlePath)
          Constructs a TreePath containing only a single element.
  TreePath(Object[] path)
          Constructs a path from an array of Objects, uniquely identifying the path from the root of the tree to a specific node, as returned by the tree's data model.
protected TreePath(Object[] path, int length)
          Constructs a new TreePath with the identified path components of length length.
protected TreePath(TreePath parent, Object lastElement)
          Constructs a new TreePath, which is the path identified by parent ending in lastElement.
 
Method Summary
 boolean equals(Object o)
          Tests two TreePaths for equality by checking each element of the paths for equality.
 Object getLastPathComponent()
          Returns the last component of this path.
 TreePath getParentPath()
          Returns a path containing all the elements of this object, except the last path component.
 Object[] getPath()
          Returns an ordered array of Objects containing the components of this TreePath.
 Object getPathComponent(int element)
          Returns the path component at the specified index.
 int getPathCount()
          Returns the number of elements in the path.
 int hashCode()
          Returns the hashCode for the object.
 boolean isDescendant(TreePath aTreePath)
          Returns true if aTreePath is a descendant of this TreePath.
 TreePath pathByAddingChild(Object child)
          Returns a new path containing all the elements of this object plus child.
 String toString()
          Returns a string that displays and identifies this object's properties.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreePath

public TreePath(Object[] path)
Constructs a path from an array of Objects, uniquely identifying the path from the root of the tree to a specific node, as returned by the tree's data model.

The model is free to return an array of any Objects it needs to represent the path. The DefaultTreeModel returns an array of TreeNode objects. The first TreeNode in the path is the root of the tree, the last TreeNode is the node identified by the path.

Parameters:
path - an array of Objects representing the path to a node

TreePath

public TreePath(Object singlePath)
Constructs a TreePath containing only a single element. This is usually used to construct a TreePath for the the root of the TreeModel.

Parameters:
singlePath - an Object representing the path to a node
See Also:
TreePath(Object[])

TreePath

protected TreePath(TreePath parent,
                   Object lastElement)
Constructs a new TreePath, which is the path identified by parent ending in lastElement.


TreePath

protected TreePath(Object[] path,
                   int length)
Constructs a new TreePath with the identified path components of length length.


TreePath

protected TreePath()
Primarily provided for subclasses that represent paths in a different manner. If a subclass uses this constructor, it should also override the getPath, getPathCount, and getPathComponent methods, and possibly the equals method.

Method Detail

getPath

public Object[] getPath()
Returns an ordered array of Objects containing the components of this TreePath. The first element (index 0) is the root.

Returns:
an array of Objects representing the TreePath
See Also:
TreePath(Object[])

getLastPathComponent

public Object getLastPathComponent()
Returns the last component of this path. For a path returned by DefaultTreeModel this will return an instance of TreeNode.

Returns:
the Object at the end of the path
See Also:
TreePath(Object[])

getPathCount

public int getPathCount()
Returns the number of elements in the path.

Returns:
an int giving a count of items the path

getPathComponent

public Object getPathComponent(int element)
Returns the path component at the specified index.

Parameters:
element - an int specifying an element in the path, where 0 is the first element in the path
Returns:
the Object at that index location
Throws:
IllegalArgumentException - if the index is beyond the length of the path
See Also:
TreePath(Object[])

equals

public boolean equals(Object o)
Tests two TreePaths for equality by checking each element of the paths for equality. Two paths are considered equal if they are of the same length, and contain the same elements (.equals).

Overrides:
equals in class Object
Parameters:
o - the Object to compare
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
Returns the hashCode for the object. The hash code of a TreePath is defined to be the hash code of the last component in the path.

Overrides:
hashCode in class Object
Returns:
the hashCode for the object
See Also:
Object.equals(java.lang.Object), Hashtable

isDescendant

public boolean isDescendant(TreePath aTreePath)
Returns true if aTreePath is a descendant of this TreePath. A TreePath P1 is a descendent of a TreePath P2 if P1 contains all of the components that make up P2's path. For example, if this object has the path [a, b], and aTreePath has the path [a, b, c], then aTreePath is a descendant of this object. However, if aTreePath has the path [a], then it is not a descendant of this object.

Returns:
true if aTreePath is a descendant of this path

pathByAddingChild

public TreePath pathByAddingChild(Object child)
Returns a new path containing all the elements of this object plus child. child will be the last element of the newly created TreePath. This will throw a NullPointerException if child is null.


getParentPath

public TreePath getParentPath()
Returns a path containing all the elements of this object, except the last path component.


toString

public String toString()
Returns a string that displays and identifies this object's properties.

Overrides:
toString in class Object
Returns:
a String representation of this object

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

7 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-1596
Document créé le 29/08/06 21:21, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-javax/swing/tree/TreePath.html Document affiché 2 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

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

Document genere en :
0,35 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Celui qui déplace la montagne, c'est celui qui commence à enlever les petites pierres.

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