Hi Inuka,
Thanks for your explaination.
My code of the View is something like (for search):
JButton searchButton = new JButton("Search");
searchButton.addActionListener(new SearchRecord());
And the inner class SearchRecord is my Controller:
private class SearchRecord implements ActionListener {
public void actionPerformed(ActionEvent ae) {
...
tableModel = controller.findRecord(criteria);
mainTable.setModel(tableModel);
}
}
The controller.findRecord() method talks to the DB and creates the Model, which implements the AbstractTableModel interface. Then the JTable's table model will be updated by the setModel() method and the view will be changed.
So, in this design it is the controller who talks with the DB. Do you think this design is OK? I feel it is quite "nature"
Can kindly share your code with me for how to use the model to do the job?
Thanks.
Cheers,
Zhang Jin