This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You shouldn't recreate the JTable each time. Instead, use a TableModel (DefaultTableModel is the easiest) and simply call setModel when you select a node. That way, you don't need to remove and add JTables each time.
But you do see the table header? Do you call fireTableRowsInserted when you add rows? Do you cann fireTableRowsDeleted when you remove rows (like clear the table)?
fireTableDataChanged is meant for when the contents of multiple cells has changed, as an alternative to fireTableRowsUpdated.
kannan vinayagam Duraiswamy
Joined: Jan 12, 2009
in the add method
but still i am able to see rows - but with no values in it
i seen the fireTableRowsInsterted method in that - it create a tablemodelevent and send to its listeners -
but in my table model i didnt declare any tablemodel listener - is it mandatory to declare a table model listener?
The JTable is its own TableModelListener. It will attach itself to the model when you call getModel() - either directly or by specifying the model in the JTable constructor.
I really hope your displayNodeDetails is a LinkedHashMap, because otherwise you're lying to the listeners. You're telling them that you added an element at the end but for a HashMap or TreeMap that's certainly not the case.