In reply to Anonymous.
EditListAction
If you which to use a different model or different data
If you wish to use a different model or different data,
In case you’d like to “modernize” the ActionListener:
/*
* Create the popup editor
*/
private void createEditPopup()
{ ….
editTextField.addActionListener(e ->
(Typing code looks horrible, so I drop the rest.)
ListAction
By default the Enter will will be used to invoke the Action
By default the Enter key will be used to invoke the Action
from the keyboard although you can specify and KeyStroke you wish.
from the keyboard, although you can specify any KeyStroke you wish.
All the best
Jörg
]]>In reply to Rob Camick.
Thanks for the explanation.
]]>In reply to Anonymous.
When creating a JList with a String array a simple anonymous inner class is used for the model and only contains getSize() and getElementAt(…) methods. There are no methods to update the model, which is why the simple implementation requires the DefaultListModel.
]]>Hello Rob,
thanks for the code. I just tested under java 25 and found that EditListAction doesn’t work if a String array is passed to the JList constructor. Maybe that’s what you meant when writing you must use the DefaultListModel. Still I thought that if only String data will be saved I could use a String[] parameter. So I would prefer the JList creation in the example implementation code to look like JList list = new JList(myDefaultListModel); to prevent any misunderstanding.
Thanks again
Jörg
]]>It’s 2025 and this is still helping folks. It just saved me a ton of time and pulled me out of some rabbit holes where I was exploring other solutions. Thanks!
]]>Mi mas sincero agradecimiento a quien compartió su trabajo de manera altruista, eso ya no se ve, soy un programador que esta aprendiendo el lenguaje y me ayudo MUCHISIMO, gracias de nuevo al autor
]]>Thank you, man! After 16 years, I found this article and saved myself thousands of headaches and hours
]]>This was grreat to read
]]>Great reading your blogg
]]>Thanks for sharing such knowledge.
]]>