This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Navigation Event in JTable

 
Dvir G.
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I didn't get a solution to create a JTable as a row in other JTable, So I changed to UI design for two seperate JTables with Master-Details relations between them.
However, I am still having troubles to create the relations between the Tables, by capturing navigation events in the master table and populate the details table with relevant data.
Does anyone have an example for it?

I didn't find events like CurrentRowChanged or anything near, do you have any idea where should be an event like this?

Thanks,
Dvir
 
praveen kumar gudapati
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
masterTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
DefaultListSelectionModel defaultListSelectionModel =
(DefaultListSelectionModel) e.getSource();

if (!defaultListSelectionModel.isSelectionEmpty()) {
// get Corresponding Children here and show them in
//detail table
} else {
// clear the children in detail table
}
}
});

The main idea is to add a ListSelectionListener to the master table and keep listening for changes.
Hope this helps you.
 
Dvir G.
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It did help.
Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic