The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
luck, db
There are no new questions, but there may be new answers.
Rob Spoor wrote:SwingUtilities.updateComponentTreeUI. Your existing components already have a UI set, and you need to tell them to update it to that belonging to the new LAF. Call that method with your top-level window(s) as arguments and it will update the UI of all components.
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:In Java 6, line 2613 of BasicListUI.java (check src.zip inside your JDK folder) is That means that either the list is null, or it has no model. My guess is the latter; perhaps the old ListUI removes the old model and the new ListUI doesn't set a new one.
int size = list.getModel().getSize();
list has no model
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
naved momin wrote:
Rob Spoor wrote:In Java 6, line 2613 of BasicListUI.java (check src.zip inside your JDK folder) is That means that either the list is null, or it has no model. My guess is the latter; perhaps the old ListUI removes the old model and the new ListUI doesn't set a new one.
yes my jlist has a default model but i dont understand the "new" and "old" list
i m not making any new list here so where does the new list arises from ?
and how to solve my problem ?
int size = list.getModel().getSize();
this gives 12 , yes i have 12 items in jlist
Where does this give 12? Directly before the call to SwingUtilities.updateComponentTreeUI(list);? What does it give directly after that call?
list has no model
i guess list always has a "default model" when we didn't explicitly give one , isn't it ?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:
naved momin wrote:
Rob Spoor wrote:In Java 6, line 2613 of BasicListUI.java (check src.zip inside your JDK folder) is That means that either the list is null, or it has no model. My guess is the latter; perhaps the old ListUI removes the old model and the new ListUI doesn't set a new one.
yes my jlist has a default model but i dont understand the "new" and "old" list
i m not making any new list here so where does the new list arises from ?
and how to solve my problem ?
I never mentioned "new" and "old" lists, I mentioned new and old ListUIs. ListUI is the base class of the object responsible for providing the look and feel of a JList. The LAF sets this ListUI. If you change the LAF, this will remove the old ListUI and set a new one for the JList. You don't do this explicitly, the API does it when you update the JList's UI which you in turn do by updating the UI of the entire component tree.
int size = list.getModel().getSize();
this gives 12 , yes i have 12 items in jlist
Where does this give 12? Directly before the call to SwingUtilities.updateComponentTreeUI(list);? What does it give directly after that call?
list has no model
i guess list always has a "default model" when we didn't explicitly give one , isn't it ?
You're actually right on that one. If a JList is created without an explicit model a new one is created for it. Calling setModel with null as its arguments will cause an IllegalArgumentException. In other words, list.getModel() could never be null. That means that in that line list must be null.
BasicListUI has a private field of type JList. This is the one from the line I posted before. Initially it's null. It's given a value when its installUI method is called. This is done when the ListUI object is set for the JList. It's set to null again when its uninstallUI method is called. This is done when the ListUI is removed from the JList.
What this tells me is that the BasicListUI's internal event listener is still being used after the BasicListUI is removed from the JList. This should usually never occur; removing the BasicListUI should also unregister all of its internal event listeners. The only reason I can think of is that some code (written by you perhaps?) is getting all of the JList's listeners (in this case ListSelectionListener) and doing something that keeps them alive (perhaps adding them again to the same JList or another one). As a result, this listener is called when it shouldn't be.
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
I brought this back from the farm where they grow the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|