1

I build a JTable in which every cell is a JTable itself. I need to make the cells of the nested (inner) tables clickable so that some additional information will be displayed in a pop-up window on a mouse click.

What is the best way to do this? Should I define every cell as a button?

Thank you in advance.

user3032925
  • 81
  • 1
  • 1
  • 6
  • Have you read something about MouseListeners (http://docs.oracle.com/javase/tutorial/uiswing/events/mouselistener.html). What have you tried yet? – Thomas Jun 10 '14 at 16:54
  • I have looked through this tutorial very superficially. I am an absolute newbie to java.swing, so I wanted to ask experienced programmers for directions before I dive into it. – user3032925 Jun 10 '14 at 17:32
  • take a look at http://stackoverflow.com/a/1378120/66207 – keuleJ Jun 10 '14 at 17:53
  • I have added a MouseListener to the inner nested table and it had no effect. However when I did the same to the outer table it worked. – user3032925 Jun 10 '14 at 19:40
  • Is it possible that the inner table is somehow deaf to mouse events because of the nestedness? How can one overcome this problem? – user3032925 Jun 10 '14 at 19:43

1 Answers1

1

Instead, create two instances of JTable, master and detail. In a ListSelectionListener added to master, update the model displayed by detail using setModel(), as shown here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045