JDK-4231298 : JComboBox renderer called for invisible cells
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1999-04-20
  • Updated: 2000-04-19
  • Resolved: 2000-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
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
14-06-2004

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. ======================================================================
11-06-2004

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
06-04-2000