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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 3 of 3

Thread: Getting code working with gui

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Getting code working with gui

    I'm a relative novice to java, and especially swing, but I recently decided to try and make a simple ticktacktoe game, no AI, just the basic mechanics.

    The board will represented by a two dimensional, 3 x 3, array, with each index representing a square on the ticktacktoe board.

    When a space is clicked, either an 'x' or an 'o' is inserted into the corresponding index.

    What I'm having trouble with is relating the array to an image of a ticktacktoe board. How will the indexes of the array be related to the squares on the board? When the user clicks a certain square on the board, how will the computer know which index of the array to place a value in?

    Apologies if you find this offensively simple.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,334
    Thanks
    181
    Thanked 830 Times in 773 Posts
    Blog Entries
    5

    Default Re: Getting code working with gui

    Not offensively simple, just hard to answer given the generality. Could be implemented in a number of ways. Recommend you have a go and if you encounter problems post again as they come along. And read the final link below

    This thread has been cross posted here:

    http://www.java-forums.org/awt-swing/40963-ticktacktoe-display.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    See The problems with cross-posting

    Last edited by copeg; March 21st, 2011 at 09:01 PM.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting code working with gui

    Alright, thanks. I think I've been set in the right direction.

Similar Threads

  1. Replies: 4
    Last Post: August 10th, 2011, 11:16 AM
  2. Code working, but not the way I thought...
    By JLogan3o13 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 28th, 2010, 12:34 PM
  3. can' stop working a part of code.plzz help
    By kyros in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 30th, 2010, 03:10 PM
  4. Code Stop working after converting to jar?
    By Ron6566 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 16th, 2010, 12:17 PM
  5. Replies: 4
    Last Post: January 26th, 2009, 11:03 PM