Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

I need assistance

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Atakpa!
 
Marshal
Posts: 22395
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseAMeaningfulSubjectLine next time.
 
Atakpa Daniel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I think she's lovely. It's this tiny ad that called her crazy:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic