Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I allow only unique strings in a JList?

I have a JList that holds a bunch of strings . I would like it to act like a Set , so that it will only hold unique values . Is there any way to achieve this without checking that a new string doesn't already exist there ?

like image 309
Geo Avatar asked Dec 18 '25 17:12

Geo


1 Answers

take a look at the docs: 1.4.2 | Java 6

You can set your own ListModel via JList#setModel(ListModel) which might be backed by e.g. a HashSet instead of the Vector which is used by default.

See also ListModel and AbstractListModel

like image 150
Argelbargel Avatar answered Dec 20 '25 06:12

Argelbargel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!