• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Radio Buttons

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am devoloping a Tic Tac Toe game which plays Computer Vs User but i dont know how i would design a radio button which makes a choice who will play first
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you know how radio buttons work in general? Have you worked through the relevant section of the Java Tutorial?

I'll move this to the AWT/Swing/GUI forum, since there seems to be nothing applet-specific in the question.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yugendra Reddy Guvvala:
...choice who will play first



If I understand your problem correctly, you want something which will decide who gets to play first, just like flipping a coin or something and you want to represent it using a radio button.

The Random class has many useful methods which you can use. First which comes to mind is the nextBoolean().
 
Yugendra Reddy Guvvala
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I have developed the TIC TAC TOE application in which user plays with computer my question is
I want to have a window displayed first asking whether the user have to play first or the computer. Which should have 2 radio buttons and one yes button and one cancel button and the window should return either user or computer to the program then the game should start accordingly
I know how to do it in HTML but not in JAVA I tried some radio button examples but could not find current answer relevant to my question
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the user can decide who is first, I think you can use the raido button swing and it's easy , you need read the tutorial.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What specifically are you struggling with? If you have code that shows two radio buttons, and code that checks which of the buttons is selected, then what you're trying to do should be easy, shouldn't it? What do you have so far?
 
grapes are vegan food pellets. Eat this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic