Checkboxes in a combobox popup
jasper.potts at oracle.com
Mon Sep 16 07:58:56 PDT 2013
You could try http://docs.oracle.com/javafx/2/api/javafx/scene/control/ScrollPane.html#setFitToWidth(boolean)
Or what about using MenuButton with check box menu items?
On Sep 16, 2013, at 5:44 AM, Werner Lehmann <lehmann at media-interactive.de> wrote:
> Never mind. I tried to cut some corners reusing a combobox for a "checkbox list popup" but this got too complicated. I am using a ComboBoxBase extending class now.
> Unfortunately it is still quite hard to determine a useful listview size for the popup. The original combobox uses package private stuff and hard casts on the listview's virtual flow. Obviously I cannot do this.
> Any idea how I can get rid of the horizontal scrollbar on the listview? Is there trick how to size the cells so that they always get the available horizontal space - but not more?
> On 14.09.2013 00:13, Werner Lehmann wrote:
>> I am displaying checkboxes in the popup of a combobox via custom cell
>> factory. Only problem is that a click on the checkbox actually hides the
>> popup, even before that checkbox was selected. As I can see, the
>> combobox skin has a MOUSE_PRESSED event filter which hides the popup.
>> Current workaround is:
>> - get the listview from the combobox skin
>> - set a MOUSE_PRESSED filter on its parent
>> - in the filter detect a click on a checkbox (sets a flag)
>> - override combobox.hide, ignore the hide if the flag was set before
>> The other workaround is to make listview think that the click was on a
>> scrollbar by adding "track" to the styleclasses of all checkbox skin
>> nodes. Then the listview would ignore the click, too.
>> Both options seem to be... less optimal. Any other idea?
More information about the openjfx-dev