As per my comment to nfechner, it really depends on how you've constructed your JList. If you've used the JList(ListModel) or JList(Vector) constructors you can potentially amend the consents of your model through a call to getModel() or in the case of Vector simply maintain a reference to the Vector and amend that (providing you fire an event aftewards to notify any model listeners).
Up vote 3 down vote favorite share g+ share fb share tw.
I want to add objects to a JList which has already been instantiated by the Netbeans genrated code. I can't pass my own list model in the JList constructor as I can't modify the Netbeans generated code. How can I add object to that JList.
Java gui swing jlist link|improve this question asked Jan 22 '10 at 13:48Yatendra Goel2,9591253116 69% accept rate.
As per my comment to nfechner, it really depends on how you've constructed your JList. If you've used the JList(ListModel) or JList(Vector) constructors you can potentially amend the consents of your model through a call to getModel(), or in the case of Vector, simply maintain a reference to the Vector and amend that (providing you fire an event aftewards to notify any model listeners). However, I'm fairly sure there are "hooks" in the Netbeans IDE to allow you to specify a specific model implementation, which will then cause the code to be auto-generated to include this.
The Netbeans generated the JList by passing the AbstractListModel. And I didn't find the way change the model so that it can generate that JList acc. To that model... – Yatendra Goel Jan 22 '10 at 14:09.
Modify the generated list model. You can get it via: See JList#getModel().
This will only work if you've constructed the JList with a ListModel or Vector. Instantiating is using the default constructor or Object will create a read-only ListModel. – Adamski Jan 22 '10 at 13:59 You're right, of course.
In that case you would probably have to set a new model. – nfechner Jan 22 '10 at 14:02.
It's possible to set your own model to the already instantiated JList, see JList#setModel(ListModel) You can pass the model extended from DefaultListModel, which supports add and remove methods.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.