Jump to content

Dear OSbot, can you help me with this?


Recommended Posts

Posted (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 by Sebastian
Posted

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...

Posted

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);




            }

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...