Sebastian Posted April 11, 2016 Share Posted April 11, 2016 (edited) First of all, i don't know if i may post things like this on this forum, because it's not OSbot related, but it is JavaFX related. Which is related to make bot scripts. So in class i got an assignment. We need to make a JavaFX project. In this project we need to add questions and RadioButtons. I did by making an array for all the questions. And put that into a for loop so i don't have to write a long line of code. This is my for loop: for(int i=0; i<vragen.length; i++) { group[i] = new ToggleGroup(); Label label = new Label((i+1) + vragen[i]); grid.add(label, 0, i); eens[i] = new RadioButton("eens"); eens[i].setToggleGroup(group[i]); grid.add(eens[i], 1, i); oneens[i] = new RadioButton("Oneens"); oneens[i].setToggleGroup(group[i]); grid.add(oneens[i], 2, i); geen_mening[i] = new RadioButton("Geen mening"); geen_mening[i].setToggleGroup(group[i]); grid.add(geen_mening[i], 3, i); } I'm sorry for the language, it's dutch. So this is good, but now i have a problem. The radioButtons needs to give a function. For example: Eens (Agree) = i++; (Give 1 point when you select Agree) Oneens (Disagree) = i--; (Give -1 point when you select Disagree) When i click on the button Submit, it should give an output. I've been struggling with this problem for ages now. You guys are my last hope. Hope ya'll can help me! Sincerely your's, Sebastian. Edited April 11, 2016 by Sebastian Quote Link to comment Share on other sites More sharing options...
Token Posted April 11, 2016 Share Posted April 11, 2016 I'm not very familiar with JavaFX but window controls generally rely on events. Also if you want to be a serious programmer you don't write code in anything but english. Quote Link to comment Share on other sites More sharing options...
Sebastian Posted April 11, 2016 Author Share Posted April 11, 2016 I'm not very familiar with JavaFX but window controls generally rely on events. Also if you want to be a serious programmer you don't write code in anything but english. Thanks for the reply. As i said, it's for my school project. Our main language in The Netherlands is Dutch. My teacher wants us to program in dutch... Quote Link to comment Share on other sites More sharing options...
Token Posted April 11, 2016 Share Posted April 11, 2016 Thanks for the reply. As i said, it's for my school project. Our main language in The Netherlands is Dutch. My teacher wants us to program in dutch... They ask you to use JavaFX in school? Quote Link to comment Share on other sites More sharing options...
Sebastian Posted April 11, 2016 Author Share Posted April 11, 2016 They ask you to use JavaFX in school? Yes. Because they think JavaFX is a good way to learn Java and work with classes. Quote Link to comment Share on other sites More sharing options...
Alek Posted April 11, 2016 Share Posted April 11, 2016 They ask you to use JavaFX in school? Well do you expect them to teach awt? 3 Quote Link to comment Share on other sites More sharing options...
Token Posted April 11, 2016 Share Posted April 11, 2016 Well do you expect them to teach awt? Idk... In school it was all console based for me... Quote Link to comment Share on other sites More sharing options...
The Hero of Time Posted April 11, 2016 Share Posted April 11, 2016 last hope. stackoverflow Quote Link to comment Share on other sites More sharing options...
Sebastian Posted April 12, 2016 Author Share Posted April 12, 2016 I got it! If you guys are interested, i'm willing to translate everything to english and publish it here. Could help some people who are learning basic Java. Quote Link to comment Share on other sites More sharing options...
Psvxe Posted April 12, 2016 Share Posted April 12, 2016 I got it! If you guys are interested, i'm willing to translate everything to english and publish it here. Could help some people who are learning basic Java. for(int i=0; i<questions.length; i++) { group[i] = new ToggleGroup(); Label label = new Label((i+1) + questions[i]); grid.add(label, 0, i); agree[i] = new RadioButton("Agreed"); agree[i].setToggleGroup(group[i]); grid.add(agree[i], 1, i); disagree[i] = new RadioButton("Disagree"); disagree[i].setToggleGroup(group[i]); grid.add(disagree[i], 2, i); no_opinion[i] = new RadioButton("No opinion"); no_opinion[i].setToggleGroup(group[i]); grid.add(no_opinion[i], 3, i); } Quote Link to comment Share on other sites More sharing options...