<Swing Dev> Updating a JComboBox's values at popup-opening-time

Alexander Potochkin Alexander.Potochkin at Sun.COM
Fri Aug 17 08:52:13 UTC 2007


Hello Clemens

It sounds very similar to the bug 4743225

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4743225

As far as I know there is no any good workaround for this problem, sorry

alexp


> Hello,
> 
> This is both a question and (if its really a problem) maybe an idea
> for enhancement.
> 
> I've a JComboBox which should update its values at the time it is
> opened (because the come from a source which changes from time to time
> during the life of the JComboBox and I don't want to update it
> periodically).
> What I did was to register a PopupListener and changed the item of the
> ComboBox but the problem was that the Popup already existed - and
> although its values were updated its size was not.
> If I e.g. had 1 entry before the update and 4 afterwards I got a list
> with the size of 1 entry with very small scrollbars.
> 
> The root of the problem seems to be that there is no legal way to
> access the BasicComboPopup (or whatever its called), as far as I've
> seen.
> 
> Could my stuff be done in another way which would not cause the
> problems mentioned above? I currently did a hack which calls
> showPopup/hidePopup in the listener so that the too small list is
> hidden and afterwards the larger list appears but thats really a hack.
> 
> I wonder wether it would be ok to work on that stuff so that the list
> re-calculates its size also when items are removed/added when the
> popup is already visible? Do you think that could break something?
> 
> Please feel free to send commend, I would be really happy about suggestions.
> 
> lg Clemens




More information about the swing-dev mailing list