Swing Models
I'm just reading the article "The Swing Architecture Overview" (http://java.sun.com/products/jfc/tsc/articles/architecture/) and I have this question. When I create a Component,ll ets say a table , with the constructor
JTable comp= new JTable(mymodel)
comp turns into a TableModelListener?. So what if the model fire events but not to this table? the table is not update inmediatly? is updated until the next repaint?
In a button, once is pressed, is not redrawn inmediatly right? Is redrawn when the model fire the events?
# 1
The JTable class is just the glue. It glues together the model, view, and controller classes that are hidden from us (package-private). The interactions are no different than regular MVC interactions. MVC is intrinsic to Swing.
# 2
That's good information. But I still wonder, if when I call table.setModel() the default, pr the old, are "forgotten". And when the table is updated, inemdiatly or just when the model fire the event TableChanged?Another thing, sorry about my english, It's not my native language.
# 3
Yeah, when you call jTable.setModel() you override the old model, and I believe the old model is forgotten. When an event happens on that JTable, it will inform the new model, not the old one. Furthermore, when an event is fired it goes through a bit of communication to all the system components (i.e. all the components in JTable such as TableModel). By default it has event listeners for editing the table, in which the table is updated immediately (the tableChanged method doesn't just decide to wait a few seconds before acting). But you can also add external objects as the event listeners, in which case it's up to you to change things.
On a side note, it's the JTable class that has the tableChanged method, not its model TableModel. I believe this is because the MVC components communicate to eachother through the JTable container / glue.