Jump to content

Dear OSbot, can you help me with this?


Sebastian

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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




            }
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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