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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -