java - How to change background if I choose RadioButton and click Button -
i use javafx, new in javafx. app. if choose radiobutton have change background in other vbox. code.
hbox box2,box1; vbox vbox1, vbox2; titledpane tp1,tp2; stackpane stackpane,stackpane2 ; radiobutton button1 ,button2,button3; button dugme1, dugme2; label labela1,labela2; checkbox cek1,cek2,cek3,cek4; @override public void start(stage primarystage) { hbox root = new hbox(); // stackpane stackpane = new stackpane(); stackpane2 = new stackpane(); vbox1 = new vbox(); vbox1.setpadding(new insets(10, 10, 10, 10)); vbox1.setspacing(10); vbox2 = new vbox(); vbox2.setpadding(new insets(10, 10, 10, 10)); vbox2.setspacing(10); labela2 = new label("operativni sistemi"); vbox2.getchildren().add(labela2); cek1 = new checkbox("windows"); vbox2.getchildren().add(cek1); cek2 = new checkbox("linux"); vbox2.getchildren().add(cek2); cek3 = new checkbox("ios"); vbox2.getchildren().add(cek3); cek4 = new checkbox("android"); vbox2.getchildren().add(cek4); dugme2 = new button("klikni"); vbox2.getchildren().add(dugme2);
these radiobutton .
labela1 = new label("boje"); vbox1.getchildren().add(labela1); button1 = new radiobutton("crvena"); vbox1.getchildren().add(button1); button2 = new radiobutton("plava"); vbox1.getchildren().add(button2); button3 = new radiobutton("bela"); vbox1.getchildren().add(button3); dugme1 = new button("klikni"); vbox1.getchildren().add(dugme1); stackpane.getchildren().add(vbox1);
and have in vbox2 change background if choose radiobutton.
stackpane2.getchildren().add(vbox2); stackpane.setprefsize(150, 150); stackpane.setstyle("-fx-background-color: gainsboro;-fx-border-color: `blue;");` stackpane2.setprefsize(300, 150); stackpane2.setstyle("-fx-background-color: gainsboro;-fx-border-color: `blue;");` root.getchildren().add(stackpane); button controlbutton = new button("change top"); root.getchildren().add(stackpane2); root.setalignment(pos.center); vbox.setmargin(stackpane, new insets(10, 10, 10, 10)); vbox.setmargin(controlbutton, new insets(10, 10, 10, 10)); scene scene = new scene(root, 550, 250); primarystage.settitle("dusan petrovic"); primarystage.setscene(scene); controlbutton.setonaction(new eventhandler<actionevent>() { @override public void handle(actionevent event) { changetop(); } }); primarystage.show(); } private void changetop() { observablelist<node> childs = this.stackpane.getchildren(); if (childs.size() > 1) { // node topnode = childs.get(childs.size()-1); topnode.toback(); } } public static void main(string[] args) {
Comments
Post a Comment