/help
I have a Vbox object, and I want to insert inside 4 "radio buttons" and beside each one of them a "TextField".
It suppose to look like the first picture:
The thing is, I want to do this with code and not through SceneBuilder.
I'm just struggling with how to insert objects inside Vbox..
I've created 4 TextField in size of(Vbox.Wideth - 50, Vbox.Height) ) (I'll leave 50 of width for the radio button)
But I don't know how to insert the textField inside the Vbox
Need help, thank you!
46 Replies
⌛
This post has been reserved for your question.
Hey @Yarden! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
This is my original sceneBuild build:
in the middle it's the Vbox named "vboxForAnswers"
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I was thinking exactly about the first way, but yeah I'll have to find a way to do the functionality..
How can label help? I barely ever used it
Isn't that just a text holder?
And I don't know listView, i'll try to search about it
And thank you very much
I can make a functionality between the radio and the text by saving the index of the radio button and then look what the text is inside this index right?
And then i'll try to match it with the question, if it's the same text then it's the correct answer
vBox.add(...)
Didn't work
So I did addChildren and i got this (the first picture)
It seems like the text's bar size can't be changed, it's always the same height and width (picture 2)
Even if i'll put 200 instead of vbox.width.. it will remain the same size
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I'm trying to do it with label, but label doesn't have an eventHandler... I'm totally stuck
i mean, setOnAction so I can press on it
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I gave up on the radio button
I'll do only label which you press and get it's text
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I didn't use listview since I don't know it
I'm on youtube now to learn about it
I was thinking only about putting 4 labels and then when you press on a label it will compare with the right answer.
But I'll just move to listview
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I don't know anymore how to do this with radio-buttons, I'm totally stuck with it
I'll learn about listview, hopefully I'll manage to do this
The aim is to do this properly, but I also have a dead-line with the university, i have to find a solution
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Do you mean methods which do different operations on the same time?
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Okie my bad sorry
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
yeah, to be honest I'm trying to break everything to many different methods with unique roles.
What I sent you is the initialize method where I mixed things up just to make sure it works.
But I've failed it
Something like this
One method was for initializing the question on the top of the window
Other method for the answers
And other for the poping message when the game is over
Is it bad?
But my initialize method is totally messed up right now since i'm lost 🫠
But i'm totally open for criticizing since I know I'm not good at this
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Done, opened a new one
And agree!
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Nope
We learn in the university only about java-FX and basic coding
and ofc generics and few other stuff
It's called "Java advanced"
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Yes ofc
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
It's not limited, I can put as many questions as I want
Ok i'll follow
Thank you very much ❤️
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
"is it supposed to keep track of correct answer"
Is it a question or statement?
Aaa got it now
Ok
Will do it
(1) Make a class called Question give it the question and the answers, give it which answer is correct, give it an isCorrect method
and then TEST the class
(2)then make a Quiz class, give it a way to load questions, give it a getRandomQuestion() method.
(3)keep track of correct answer or whatever is required for the quiz to be correct, add it in the quiz class
and add it with different methods for each thing
then test the quiz.
(4)only AFTER u have all of that running do u make the QuizView class where u put the javaFX
and u already know how to pre-initialise a controller, so u can make the QuizViewController constructor take a Quiz instance and link the quiz to the javaFX that way
and it wont be mixed up inside the javaFX!!
Organized it so it will be next to my eyes
@borgrel
Something like this?
Database class contains the bank of words
Question class get an index and produces an object which absorbs question, right answer, 3 wrong answers from the bank (Database).
"getAnswers()" method needs to be fixed, but it shows you the question and the 4 answers and returns the Strings which includes them
And of course main method
I've renamed getAnswers() to getForm()
It makes more sense
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
This is the database, it's not ok?
interfaces we've just touched it, barely ever used it
prepared statements I don't know what is this
It was a standard in out university so I got used to it, but I will change it, thank you for marking this🙏
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Okie!
So i'll get rid of the extends.
It's something I have lack of understanding in general, when I should extends and when I shouldn't
I guess I shouldn't also do "Quiz extends Question" cause I don't manage to understand how to continue this
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
ok I will
@borgrel
They said in the assignment that the array of questions we can initialize in the code.
I think that's the only way for me since I've never touched SQL
and it seems like prepared statement are based on basic understanding of SQL
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Because I need to check if my code works
I've created the database
I forgot to show you
Database I meant like a class with Questions, answers and wrong answers so I can test my code
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Post Closed
This post has been closed by <@218019068219883520>.