java - Add listener to ArrayList -
i have arraylist add objects dynamically, , have jbutton. arraylist empty when running program , jbutton set setenabled(false). want enable button whenever there 2 elements in arraylist or more , disable again if arraylist has 1 item or empty. how can achieve this?
arraylist
doesn't have sort of notification mechanism.
i suggest write own list
implementation delegates private arraylist
storage, adds ability listen notifications... or find similar within java itself. defaultlistmodel
may work you, although doesn't implement list
itself.
wiki
Comments
Post a Comment