Avatar of CSecurity
Flag for Iran, Islamic Republic of

asked on 

Append String (new Item) to JList

I have a JList (I'm using NetBeans IDE)

I tried getting DefaultListModel with jList1.GetModel()

But casting doesn't work and I get casting exception.

I tried to add a new string to jList with all possible methods, but all clears the list and adds new one!

I want to keep what jList have and just add new entry to jList, also I want to know how I can get text in xth element of jList... I don't know anything about it at all..

Please explain why I can't cast getModel() of jList to DefaultListModel

Anyway, please advice how to add a new item to jList and enumerate all texts in list.

Thanks from now!

Avatar of undefined
Last Comment

8/22/2022 - Mon