Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel switch on click  RSS feed

 
Kristers Drozds
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, first of all i'm kinda new to gui.
I'm making a Quiz with Question - Answers.
How can i make my Questions to show in Jlabel and answers on JRadiobuttons?
and when somebody clicks next button it shows next questions + answers.


 
Les Morgan
Rancher
Posts: 767
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a very basic layout. You can put a button on the bottom and more on to the next question, and use the setText method in the JRadioButton and JLabel to change the text for the next QA round.

 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As this is a GUI related issue I'll move this to the Swing forum.
 
Kristers Drozds
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les Morgan wrote:Here is a very basic layout. You can put a button on the bottom and more on to the next question, and use the setText method in the JRadioButton and JLabel to change the text for the next QA round.



Hey thanks for fast response, but i want to make that questions+ answers is taken from constructor.


and i have no idea how to make it work.
Cause i want to make a random quiz, that takes 10 questions out of 100.
I had an idea to make a list of questions and shuffle the list... but i have no idea how to make answers follow the question.

Or its just better to use setText?
 
Les Morgan
Rancher
Posts: 767
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no reason why your idea will not work, just change my object's name to TEXTS and add an appropriate constructor for it, and there you'll have it. You will need to do a little more development on your idea: I see you have 4 arguments in your constructor--my way of thinking you will need the question, the answers (to choose from), and the correct answer number, but what I gave you will work as your TESTS object with a little reworking on your part.
Kristers Drozds wrote:
Hey thanks for fast response, but i want to make that questions+ answers is taken from constructor.


and i have no idea how to make it work.

Or its just better to use setText?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!