Defaulting a comboBox's buttonCell to the cellFactory
jonathan.giles at oracle.com
Sun Jun 24 19:37:18 PDT 2012
Due to a lot of high-priority work that came in recently, I've just
returned to this topic now. The issue that I see with taking option A is
that the logic in the code would go something like this:
buttonCell = comboBox.getButtonCell() != null ? comboBox.getButtonCell() :
comboBox.getCellFactory() != null ?
With option A, when the user wants to have the button area use the cell
factory, the buttonCell will be null, and the cell factory will be
non-null. This is fine - the display will be populated with a node from
the cell factory. However, if the user wants the button area to be the
default look, and they have a cell factory, they presently have no way
of specifying that they do not want to use the cell factory.
Conversely, with the current approach, if a user wants a custom
buttonCell - they set it in ComboBox.buttonCell. If they want a custom
cell factory for the popup ListView, they set ComboBox.cellFactory. If
they want both, they set both (and create a cell from the cell factory
to set in the buttonCell, if they want the same look in both places).
Given how close we are cutting it to high resistance development
(tomorrow for my team), I am not about to make any major changes to
restructure this. I am at peace with the current design, and plan to
leave things as-is. Urs, I'm sorry I could not meet your desired approach.
On 2/06/2012 9:32 a.m., Jonathan Giles wrote:
> So, in summary, Urs and I would appreciate votes on option A or option B:
> Option A: the ComboBox buttonCell by default uses a cell from the
> provided cell factory.
> Option B: The ComboBox buttonCell DOES NOT use a cell from the
> provided cell factory, and instead requires the user to manually
> create a cell and set it in the buttonCell property.
> Option A is consistent with the approach used in JavaFX 2.1, whereas
> Option B is the current approach used in JavaFX 2.2.
> The answer to this question largely comes down to the more common use
> case when using the cell factory: do we expect users to want to use
> the same cell in the button and the list, or do we expect them to want
> to have different cells (and perhaps the default cell in the button
> I'm totally not against changing this, so I welcome your votes on this
> -- Jonathan
> On 1/06/2012 5:39 p.m., Urs Reupke wrote:
>> Hi all,
>> back in April, Jonathan proposed a change to comboBoxes that allowed
>> to separate the button's rendering from the list's rendering.
>> In the JIRA issue accompanying that discussion , he also mentioned
>> ways to render the button when the new buttonCell property is not set:
>> "If this is not set, there are two options:
>> 1) Use a cell from the ComboBox.cellFactory
>> 2) Not style the button at all, and use a default cell from the skin"
>> Now, in FX2.2b10, the buttonCell is rendered as toString if the
>> property is not set.
>> I believe that his option 1) would be a great improvement to the
>> behaviour, and Jonathan asked me to make that proposal public.
>> My reasoning is that those who need the buttonCell to be rendered
>> differently can do it, whereas those whose buttons and listcells look
>> alike don't need to think about it. From my experience, the latter
>> should be the majority.
>> I appreciate your feedback on the matter.
>> Thank you
>>  http://javafx-jira.kenai.com/browse/RT-21023
More information about the openjfx-dev