Drag & Drop functionality for JTable removes JTable column headers
Posted on 2002-05-01
I've been scratching my head for days trying to sort out why the following problem occurs but have been unable to find a solution. So I would appreciate someone's help, thanks.
I'm using Java 1.3.1
I have a JTable derived class that implements drag and drop - this works fine, no problems here. However, I want to display column headers for my JTable, so USING a created JScrollPane instance variable, I add the JTable class to it, then add it to the JPanel container that they're both contained in. Compile, run and........
NOTHING HAPPENS! No table column headers appear in the table! Code wise everything seems to be present, and in my derived JTable class I override getColumnName() and return the appropriate column name.
Now here's the strange bit. If I remove the call to add my JTable class to the JPanel container, the table column headers appear but the drag and drop operation stops working. Reintroducing the JPanel.add(JTable) line, enables drag a drop but removes the table column headers! Bizarre - but very annoying!
Can anyone tell me if I'm doing anything wrong or if there's some bug in JTable that doesn't allow both of these features to exist happily together. I think I read somewhere that this could possibly be a bug? Any working code examples would be much appreciated, and I can provide code snippets of the problem if it helps.
Thanks in advance.