_stic_
Messages postés11Date d'inscriptionsamedi 22 octobre 2005StatutMembreDernière intervention19 novembre 2009
-
24 mai 2007 à 10:22
cs_AlexN
Messages postés694Date d'inscriptionlundi 5 décembre 2005StatutMembreDernière intervention 8 janvier 2014
-
24 mai 2007 à 11:57
Bonjour, j'aimerais mettre une image à la place de l'image du dossier dans un jtree à chaque noeud. Est ce que quelqu'un sait comment faire ?
public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
/**
* icon used to display on the tree
*/
public static Icon icon= null;
/** Creates a new instance of MyTreeCellRenderer */
public MyTreeCellRenderer() {
icon = new ImageIcon(getClass().getResource("MyIcon.gif"));
}
/**
* Sets the value of the current tree cell to value.
* If selected is true, the cell will be drawn as if selected.
* If expanded is true the node is currently expanded and if leaf is
* true the node represets a leaf and if hasFocus is true the node
* currently has focus. tree is the JTree the receiver is being
* configured for. Returns the Component that the renderer uses to draw the value.
*
* Modified the TreeCellRender to match a specific nodes attributes. If
* the node is a match, then blue is used for the text color. Icon is customized
*
* @param tree the JTree being redrawn
* @param value node in the tree
* @param sel true if selected by the user
* @param expanded true if path is expanded
* @param leaf true if this node is a leaf
* @param row row number (vertical position)
* @param hasFocus true if it has the focus
* @return the Component that the renderer uses to draw the value
*/
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {