user interface - How can I create this menu button in Javafx? -
i'm working on college project, , create menu button allow users decide whether search id or search date, cannot find out how, or if it's possible.
i appreciate if tell me if possible create such button displayed in image within black circle, , how.
thanks in advance.
you can use following code:
checkmenuitem checkmenuitem1 = new checkmenuitem("id search"); checkmenuitem checkmenuitem2 = new checkmenuitem("date search"); menubutton menubutton = new menubutton(); menubutton.setgraphic(new imageview(new image(getclass().getresource("path.fileextension").toexternalform()))); menubutton.getitems().addall(checkmenuitem1,checkmenuitem2);
alternatively, can use custommenuitem
:
custommenuitem iditem = new custommenuitem(new checkbox("id search")); custommenuitem dateitem = new custommenuitem(new checkbox("date search")); menubutton menubutton = new menubutton(); menubutton.setgraphic(new imageview(new image(getclass().getresource("path.fileextension").toexternalform()))); menubutton.getitems().addall(iditem,dateitem)
update: if 2 search types should mutually exclusive, can replace checkmenuitem
radiomenuitem
:
radiomenuitem radiomenuitem1 = new radiomenuitem("id search"); radiomenuitem radiomenuitem2 = new radiomenuitem("date search"); togglegroup togglegroup = new togglegroup(); togglegroup.gettoggles().addall(radiomenuitem1, radiomenuitem2);
Comments
Post a Comment