0

I'm working on a Java GUI project with SwingX where I inserted a JTable with a DefaultTableModel! The JTable has two columns (ID and path) and in principle two main features:

  • With two JButtons "+" and "-" I can add rows to the DefaultTableModel and remove selected ones!
  • With double-right click on the second column (path) a JFileChooser opens, where I can select a path, which will be set as value for the cell! For this action I implemented a CustomMouselistener and overwrote the "mousePressed" method!

My problem: After implementing this stuff, I can't edit the cell with a normal mouse-click on a cell! The cells are editable, because I can edit them with "F2" - press, but it seems that I overwrote the default functionality of the mouse!

Summarized I'm using following constructs:

  • Table with DefaultTableModel (2 columns)
  • MouseListener for JFileChooser
  • ColumnModelListener to change width of columns!

Can someone help me with this issue?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
conFusl
  • 919
  • 6
  • 12
  • 1
    perhaps you could add a button "browse" for those cells that you use to invoke JFileChooser. BTW, why do you use exclamation instead of period? – mariusm Sep 18 '14 at 07:15
  • 1
    Hm, but the purpose is to insert the paths fast - otherwise I would need to select the cell first and click on the button every time. Sorry, the exclamations are habit - nothing to do with the question or you guys! :) – conFusl Sep 18 '14 at 07:21
  • For editing columns use `TableCellEditor` instead of `MouseListener`. – alex2410 Sep 18 '14 at 07:26
  • 1
    related: http://stackoverflow.com/a/3015438/2685239 (you could put that code into your mouseClick method) – mariusm Sep 18 '14 at 07:26

0 Answers0