Bonjour,

J'ai récupéré un composant qui utilise comme renderer la classe suivante.
J'aimerais afficher dans un toolTipText le contenu de la cellule sur laquelle se trouve le curseur.
J'ai essayé de placer du setToolTipText() à 2 ou 3 endroits, mais ça ne donne rien...

Quelqu'un voit-il où je dois le mettre?
Merci!

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
public class TreeTableCellRenderer extends JTree implements TableCellRenderer {
		/** Last table/tree row asked to renderer. */
		protected int visibleRow;
 
 
		public TreeTableCellRenderer(TreeModel model) {
			super(model);
		}
 
		/**
                 * updateUI is overridden to set the colors of the Tree's renderer to
                 * match that of the table.
                 */
		public void updateUI() {
			super.updateUI();
			// Make the tree's cell renderer use the table's cell selection
			// colors.
			TreeCellRenderer tcr = getCellRenderer();
			if (tcr instanceof DefaultTreeCellRenderer) {
				DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
 
				// pour changer l'icone des feuilles
//				dtcr.setLeafIcon(null);
 
				// For 1.1 uncomment this, 1.2 has a bug that will cause an
				// exception to be thrown if the border selection color is
				// null.
				// dtcr.setBorderSelectionColor(null);
				dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
				dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
 
				// test tooltip : il affiche un tooltip mais pas rempli 
				// et donc tout petit; et que sur l'arbre ici...
//				dtcr.setToolTipText(dtcr.getText());
			}
		}
 
		/**
                 * Sets the row height of the tree, and forwards the row height to the
                 * table.
                 */
		public void setRowHeight(int rowHeight) {
			if (rowHeight > 0) {
				super.setRowHeight(rowHeight);
				if (JTreeTable.this != null
						&& JTreeTable.this.getRowHeight() != rowHeight) {
					JTreeTable.this.setRowHeight(getRowHeight());
				}
			}
		}
 
		/**
                 * This is overridden to set the height to match that of the JTable.
                 */
		public void setBounds(int x, int y, int w, int h) {
			super.setBounds(x, 0, w, JTreeTable.this.getHeight());
		}
 
		/**
                 * Sublcassed to translate the graphics such that the last visible row
                 * will be drawn at 0,0.
                 */
		public void paint(Graphics g) {
			g.translate(0, -visibleRow * getRowHeight());
			super.paint(g);
		}
 
		/**
                 * TreeCellRenderer method. Overridden to update the visible row.
                 */
		public Component getTableCellRendererComponent(JTable table,
				Object value, boolean isSelected, boolean hasFocus, int row,
				int column) {
			if (isSelected)
				setBackground(table.getSelectionBackground());
			else
				setBackground(table.getBackground());
 
			visibleRow = row;
//			System.out.println("text : "+custom.getText());
//			System.out.println("name : "+custom.getName());
//			custom.setToolTipText(custom.getText());
//			this.setToolTipText("toto");
			return this;
		}