Java Swing: List Models and Collections -



Java Swing: List Models and Collections -

i writing programme having lot of code duplication between gui aspect , info storage aspect, , wondering if proposed solution follows acceptable design principles.

basically, have info objects, have list holding more information. gui displays object, , jlist displays info in info object's list. in gui, users can add together or remove info object's list, , visually reflected in jlist.

however, results in me having maintain gui jlist , object list separately:

private void addinformation(string s) { this.listmodel.addelement(s); this.dataobject.getlist().add(s); }

(obviously simple illustration idea). means i'm using twice much memory holding both lists. acceptable me create class implemented both listmodel , list interfaces , need update single combined list/listmodel? i'm still studying @ uni , want create project best perchance can in terms of maintainability others , adherence best practices.

your gui should not hold info state of info model. improve separate model-view-controller (mvc) design. controller responsible object creation , updating model , view accordingly. actual view should responsible screen display passing arguments display. way view , model don't need know each other , there 1 info model.

if having maintain both lists consistent wrong design , introduce more bugs code.

see here mvc details.

java swing collections model jlist

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -