bonjour,
je travail avec les jtreetable :
j'ai instancié mon modele et j'affiche les deux jtreetable dans une meme maquette sur 2 jpanel aucun probleme juska maintenant,
mais j'ai ecri la fonction mousePressed je veux connaitre l'objet selectionné lorsque l'evenement est generé voila mon code :
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 public void mousePressed(MouseEvent e) { Libelle=""; if(e.getSource()instanceof JTreeTable) { // mTreeTablePanelSource : premier jtreetable if(mTreeTablePanelSource.getFocusTraversalKeysEnabled()==true){ JOptionPane.showMessageDialog(null,"source :"+mTreeTablePanelSource.getFocusTraversalKeysEnabled()); int ligne=mTreeTablePanelSource.mTreeTable.getSelectedRow(); if (ligne != -1) { if(mTreeTablePanelSource.mTreeTable.getTree().isCollapsed(ligne)){ mTreeTablePanelSource.mTreeTable.getTree().expandRow(ligne); } TreePath path = mTreeTablePanelSource.mTreeTable.getTree().getPathForRow(ligne); Node node = (Node)path.getLastPathComponent(); Libelle=node.getLibelle(); JOptionPane.showMessageDialog(null,"source"+Libelle); } } else{ //mTreeTablePanelDestination : 2 eme Jtreetable if(mTreeTablePanelDestination.getFocusTraversalKeysEnabled()==true){ JOptionPane.showMessageDialog(null,"destination :"+getFocusTraversalKeysEnabled()); int ligne=mTreeTablePanelDestination.mTreeTable.getSelectedRow(); if (ligne != -1) { if(mTreeTablePanelDestination.mTreeTable.getTree().isCollapsed(ligne)){ mTreeTablePanelDestination.mTreeTable.getTree().expandRow(ligne); } TreePath path = mTreeTablePanelDestination.mTreeTable.getTree().getPathForRow(ligne); Node node = (Node)path.getLastPathComponent(); Libelle=node.getLibelle(); JOptionPane.showMessageDialog(null,"source"+Libelle); } } } } }
connaitre l'objet (1 ou 2) selon celui pressé
toujours il passe par le premier meme si je ne clique (pressed) pas sur le 2eme
Merci si je suis pas claire Merci de le signalé
Partager