i wanted ask 1 problem. want move 2 radio button in 1 column both take space textbox above them. how can this? here code , screenshot of current improper version:
please not flag question duplicate if not 100% sure, ok? not nice have question flag duplicate of other question, go other 1 , finds out common thing both programming.
gridpane formgrid = new gridpane(); formgrid.setpadding(new insets(5,5,5,5)); formgrid.setvgap(6); formgrid.sethgap(4); //first row label namelabel = new label("name"); gridpane.setconstraints(namelabel, 0, 0); textfield nameinput = new textfield(); gridpane.setconstraints(nameinput, 1, 0); label agelabel = new label("age"); gridpane.setconstraints(agelabel, 2, 0); textfield ageinput = new textfield(); gridpane.setconstraints(ageinput, 3, 0); //secondrow label colourlabel = new label("colour"); gridpane.setconstraints(colourlabel, 0, 1); textfield colourinput = new textfield(); gridpane.setconstraints(colourinput, 1, 1); label genderlabel = new label("gender"); gridpane.setconstraints(genderlabel, 2, 1); togglegroup pickgender = new togglegroup(); radiobutton pickmale = new radiobutton("male"); pickmale.settogglegroup(pickgender); pickmale.setselected(true); gridpane.setconstraints(pickmale, 3, 1, 1, 1); radiobutton pickfemale = new radiobutton("female"); pickfemale.settogglegroup(pickgender); gridpane.setconstraints(pickfemale, 4, 1, 1, 1); //third row label typelabel = new label("type"); gridpane.setconstraints(typelabel, 0, 2); //combobox combobox<string> typebox = new combobox<>(); gridpane.setconstraints(typebox, 1, 2); label breedlabel = new label("breed"); gridpane.setconstraints(breedlabel, 2, 2); textfield breedinput = new textfield(); gridpane.setconstraints(breedinput, 3, 2); //fourth row label categorylabel = new label("category: "); gridpane.setconstraints(categorylabel, 0, 3); togglegroup pickcategory = new togglegroup(); radiobutton picklost = new radiobutton("lost"); picklost.settogglegroup(pickcategory); picklost.setselected(true); gridpane.setconstraints(picklost, 1, 3); radiobutton pickfound = new radiobutton("found"); picklost.settogglegroup(pickcategory); gridpane.setconstraints(pickfound, 2, 3); radiobutton pickadoption = new radiobutton("adoption"); picklost.settogglegroup(pickcategory); gridpane.setconstraints(pickadoption, 3, 3); //fifth row label descriptionlabel = new label("description"); gridpane.setconstraints(descriptionlabel, 0, 4); textarea descriptioninput = new textarea(); gridpane.setconstraints(descriptioninput, 1, 4, 2, 1); formgrid.getchildren().addall(namelabel, nameinput, agelabel, ageinput); formgrid.getchildren().addall(colourlabel, colourinput, genderlabel, pickmale, pickfemale); formgrid.getchildren().addall(typelabel, typebox, breedlabel, breedinput, categorylabel); formgrid.getchildren().addall(picklost, pickfound, pickadoption, descriptionlabel, descriptioninput);
think of other way around. "female" radio button in column 4, , right of in column 3. column 3 being forced wide enough hold 2 text fields, forcing radio button far right. if want text fields span same horizontal space 2 radio buttons, let them use both columns radio buttons occupy: i.e. let text fields span columns 3 , 4.
textfield ageinput = new textfield(); gridpane.setconstraints(ageinput, 3, 0, 2, 1); textfield breedinput = new textfield(); gridpane.setconstraints(breedinput, 3, 2, 2, 1);
now columns 3 , 4 contain 2 text fields, column 3 contains "male" radio button, , column 4 contains "female" radio button.
i'm not sure if posted whole form, might want increase column span of text area make work nicely:
gridpane.setconstraints(descriptioninput, 1, 4, 4, 1);
with changes get
(if it's important you, can avoid "female" check box being pushed right setting column span of "adoption" check box 2.)
another option (starting original code) wrap 2 radio buttons in hbox
, , place hbox
in grid pane instead of radio buttons:
radiobutton pickmale = new radiobutton("male"); pickmale.settogglegroup(pickgender); pickmale.setselected(true); radiobutton pickfemale = new radiobutton("female"); pickfemale.settogglegroup(pickgender); hbox genderbuttons = new hbox(4, pickmale, pickfemale); gridpane.setconstraints(genderbuttons, 3, 1); // ... formgrid.getchildren().addall(colourlabel, colourinput, genderlabel, genderbuttons);
however, prefer previous approach. (your mileage may vary.)
Comments
Post a Comment