Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Using comboBox to add players

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Thanked 1 Time in 1 Post

    Default Using comboBox to add players

    Hello, i want to make a game where you play against the computer. All you do is tossing a dice and the plaer who gets the highest number gets a score.

    First of all, I made a ComboBox with 4 alternatives. Player 1, 2.... up to 4. And when you have selected the amount of players i want to press done. Then in the big textfield it should say like "3 players selected". And in the next turn window it should say "Player 1 turn" and i just press play. And if i win against the computer, i get one score in the top right corner. And the score gets shown in the big text field. Does anyone know how i can type my code to make the first part happened? Just selecting players and showing how many is in the big textLog?

    If anyone could just help a bit. I would be forever in your debt!

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: Using comboBox to add players

    Add a listener to the Done button that reads the value selected in the combo box and output the corresponding number of players selected in the textfield, just as you described. That is how you'd do it by hand, and the How to Write an Action Listener tutorial should be helpful. If you're trying to do it using the Netbeans GuiBuilder, then I don't know how you'd do it, but there may be tutorials on that, too.

    Good luck!

Similar Threads

  1. Replies: 4
    Last Post: April 3rd, 2014, 05:14 PM
  2. Replies: 2
    Last Post: April 3rd, 2014, 04:44 PM
  3. add combobox to swing
    By viral.bhat in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 18th, 2014, 03:27 AM
  4. Dealing 13 cards to 4 players.
    By NewlyLearner in forum What's Wrong With My Code?
    Replies: 11
    Last Post: December 11th, 2013, 11:06 AM
  5. Java Game - Alternate between players
    By JohnQ in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 21st, 2011, 08:49 PM

Tags for this Thread