Javafx combobox not updating dropdown size upon change on realtime? -
i using javafx v8.0.25-b18.
the problem occur size of dynamic combox's dropdown list doesn't change, if had 2 items in dropdown, dropdown size 2 items, if populate dynamic combox 3 items small scrollbar inside!?, if remove item - have blank space in combox !?
i want "reset" dropdown size each time put values it, right size each time gets populated @ runtime.
to clarify more adding 3 images:
1. first screenshot shows initial dropdown size of 2
- the second screenshot shows same combox, @ runtime adding 2 values, expect have dropdown size of 4, instead dropdown size stays 2 , adds unwanted scrollbar
- last screenshot when remove items , 1 item remains in combox, expect see dropdown of 1 item, instead unfortunately see dropdown size of 2 empty space instead of second item
i adding simple code create scenario, want thank @gikkman helped getting far , code his!
public class test extends application { private int index = 0; @override public void start(stage primarystage) throws ioexception { vbox vbox = new vbox(); vbox.setspacing(10); vbox.setalignment(pos.center); final combobox<string> box = new combobox<>(); box.setprefwidth(200); box.setvisiblerowcount(10); button add = new button("add"); button remove = new button("remove"); add.setonaction( new eventhandler<actionevent>() { @override public void handle(actionevent event) { box.getitems().add("item " + index++); box.getitems().add("item " + index++); } }); remove.setonaction( new eventhandler<actionevent>() { @override public void handle(actionevent event) { if( index > 0 ) box.getitems().remove(--index); } }); vbox.getchildren().addall(add, remove, box); scene scene = new scene(vbox); primarystage.setscene(scene); primarystage.show(); } public static void main(string[] args) { launch(args); } }
try this:
box.hide(); //before set new visiblerowcount value box.setvisiblerowcount(rows); // set new visiblerowcount value box.show(); //after set new visiblerowcount value
it's works me editable combobox , think work in case.
Comments
Post a Comment