Вопрос

I'm using ResultSets to create my DefaultTableModel, so I'm thinking that it might be good to avoid using ResultSets in the view, where the DefaultTableModel populates my JTables. I suspect my reasoning is wrong, guessing that Swing components belong to the view only, but am curious if such separation would prove valuable in some cases. I think the way the ResultSet is presented potentially alters the meaning of the information shown, making it more information based that presentation based.

So, if I have a Swing DefaultTableModel, is it ever appropriate to remove it from the view and place it in the model?

Это было полезно?

Решение

It is appropriate to create a subclass of DefaultTableModel that accepts a ResultSet and does all the necessary processing. This way, the ResultSet is not directly exposed to the view so it gives you better encapsulation.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top