• Post Reply Bookmark Topic Watch Topic
  • New Topic

I need assistance  RSS feed

 
Atakpa Daniel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,
can any one please help me out.
I am working on a JSE Quiz application.
A question pops out at a time along side four options.
The player is expected to choose the correct answer.

This is where I need help:
1. I need the option field to change color on mouse point
2. I also need the option field to be sensitive to mouse click(clickable)
3. Finally after it is clicked, the program should verify
the answer and output success or failure message accordingly

How can i achieve these?

Thanks in anticipation
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you need something like:

2 or 3 areas, maybe JPanels in a JFrame, but there are options.

panelOne will have the questions built from an array of questions

panelTwo will have the 4 possible answers as JCheckBoxes, also built from an array of answers that correspond to the questions

panelThree can have JButtons like "Submit," "Cancel," "Quit," whatever your program needs.

The JButtons and JCheckBoxes will have listeners so the program knows when a choice has been made. Based on your explanation, maybe you don't need JButtons at all, and the user's first JCheckBox choice will count as the answer - a little cruel to not allow the user to change his/her mind, but maybe that's the assignment.

Do some coding and come back for help. The color changing can be added later, so don't sweat that now.
 
Jan Cumps
Bartender
Posts: 2632
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Atakpa!
 
Rob Spoor
Sheriff
Posts: 21050
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseAMeaningfulSubjectLine next time.
 
Atakpa Daniel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,at the situation where
i can avoid the use of Jbotton or check box but instead
use JText field. Now the Jtex field will be sensitive to
mouse point. Once it is clicked something should happen.

A typical example is the "Who want to be a millionar game"

I believe the explanation is clearer now.

Hoping to hear from you soon

Thanks in anticipation
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Atakpa Daniel wrote:at the situation where i can avoid the use of Jbotton or check box but instead use JText field. Now the Jtex field will be sensitive to mouse point. Once it is clicked something should happen.


I think of a JTextField as a component that allows the user to enter or change text, and this is not what I believe you want. If I understand you correctly, you want to display rows of text that the user won't change but will select on mouse click. If correct, possible solutions include use of a JList that you've added an ItemSelectionListener to, or if you want to fully roll your own, then a grid of JLabels held in a JPanel where the JLabels have a MouseListener added to them.

Luck.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!