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 4 of 4

Thread: How can I do this with my array please ?

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    68
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default How can I do this with my array please ?

    Hi, I'm not sure if I have posted this in the right section but :

    String myArray[][] =      {{" "," "," ","X","X","X"," "," "," "},
                                       {" "," "," ","X","X","X"," "," "," "}, 
                                       {" "," "," ","X","X","X"," "," "," "},
                                       {"X","X","X","X","X","X","X","X","X"},
                                       {"X","X","X","X","O","X","X","X","X"},
                                       {"X","X","X","X","X","X","X","X","X"},
                                       {" "," "," ","X","X","X"," "," "," "},
                                       {" "," "," ","X","X","X"," "," "," "},
                                       {" "," "," ","X","X","X"," "," "," "}};

    My array prints that to the screen. Is there any way I can set a size to make it bigger.

    Example, my screen size is say 600x600, but this will only take up a tiny bit of the screen, how would I make it fit full screen?

    thanks


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: How can I do this with my array please ?

    If you're using this as a model to create a GUI, then yes, you can expand the size, but if this being run as a console application then your options are much more limited.

  3. #3
    Member
    Join Date
    Oct 2012
    Posts
    68
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: How can I do this with my array please ?

    I want it to actually create a game and move the pieces around, is there a way I can create a 2D array with images in the same setup?

    thank you

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: How can I do this with my array please ?

    Sure. If this were a Swing GUI, then you could either use JLabels or graphic sprites to move around. This would require effort though to learn the Swing GUI library.

Similar Threads

  1. [SOLVED] Merge two 1D array's into a new 1D array. Trouble appending last index
    By norske_lab in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 30th, 2012, 12:57 PM
  2. Doubling The Array Size And Randomizing Array Return
    By Pingu00 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: June 27th, 2011, 10:50 AM
  3. Replies: 2
    Last Post: May 13th, 2011, 03:08 AM
  4. Replies: 2
    Last Post: May 6th, 2011, 05:19 PM
  5. 2d (4x4) array insdie a 1d array. (Block cipher)
    By fortune2k in forum Collections and Generics
    Replies: 13
    Last Post: November 23rd, 2010, 05:29 PM