United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4231298 : JComboBox renderer called for invisible cells

Details
Type:
Enhancement
Submit Date:
1999-04-20
Status:
Resolved
Updated Date:
2000-04-19
Project Name:
JDK
Resolved Date:
2000-04-19
Component:
client-libs
OS:
generic
Sub-Component:
javax.swing
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.1
Fixed Versions:
1.4.0 (beta)

Related Reports

Sub Tasks

Description

Name: dbT83986			Date: 04/20/99


When a JComboBox first drops down, the renderer is called for
every element in the list, even those elements that will not
actually be drawn on the screen. Constructing a
"ListCellRendererComponent" can be a time-consuming operation,
however. (You might need to access a database, scale fonts,
etc.) This behavior unnecessarily lengthens the amount of time
required to drop down the list as a consequence. To make matters
worse, once a renderer component is requested for *every* cell,
the combo box then requests to render components for the cells that
it actually intends to display *again*. For example, if the list
has 200 items in it and 10 will be displayed when the box drops
down, renderers are requested for all 200 (including the first 10),
then renderers are requested for the first 10 (again).

Swing should only call getListCellRenderComponent for those cells
that will actually appear on the screen when the combo box drops
down, and Swing should only request these renderers only once
during a give drop-down sequence. (Of course, you should re-render
the cells the *second* time the list drops down in case something
has changed.)
(Review ID: 57232) 
======================================================================

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
generic
merlin-beta

FIXED IN:
merlin-beta

INTEGRATED IN:
merlin-beta


                                     
2004-06-14
WORK AROUND



Name: dbT83986			Date: 04/20/99


The last item in the list will be requested during the first
drop down. Your renderer could render the first 20 or so indexes
when asked, but then ignore requests for any other indexes
until such a time as the last item in the list is requested.
Thereafter, it should render all requested indexes.
======================================================================
                                     
2004-06-11
EVALUATION

This is a performance problem and has been addressed by adding some new API to JComboBox: get/setPrototypeDisplayValue(). This API allows the UI to calculated the display size using this prototype value rather than iterated over a large list of items. See RFE 4289100 which also addresses this problem.
mark.davidson@Eng 2000-04-06
                                     
2000-04-06



Hardware and Software, Engineered to Work Together