java - Why are ListModel objects necessary? -



java - Why are ListModel objects necessary? -

let's have list called jlist1.

we want create model it, of course, utilize listmodel object. done.

defaultlistmodel<integer> numbers = new defaultlistmodel<>(); numbers.addelement(1); numbers.addelement(2); numbers.addelement(3); jlist2.setmodel(numbers);

my question why utilize list model object instead of normal list or collection. reason know of setmodel() accepts list models argument, reason these decisions?

if @ javadoc of defaultlistmodel realize provide several methods manipulate item in jlist not possible using simple collection.

if initialize list array or vector, constructor implicitly creates default list model. default list model immutable — cannot add, remove, or replace items in list. create list items can changed individually, set list's model instance of mutable list model class, such instance of defaultlistmodel.

please have @ swing tutorial on how utilize lists explained in detail.

java swing list user-interface collections

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -