Results 1 to 7 of 7
  1. #1
    nikiiz is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default how to make grid number ?

    hai,
    how to make grid number in java 2d ?
    ex:
    1 2 3 4 5 6 7 8 9 10
    11 12 13 14 15 16 17 18 19 20
    21 22 23 24 25 26 27 28 29 30
    and so on .. can anybody help ?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: how to make grid number ?

    Moved from Java 2D

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    romero4742 is offline Member
    Join Date
    Mar 2012
    Posts
    27
    Rep Power
    0

    Default Re: how to make grid number ?

    Quote Originally Posted by nikiiz View Post
    hai,
    how to make grid number in java 2d ?
    ex:
    1 2 3 4 5 6 7 8 9 10
    11 12 13 14 15 16 17 18 19 20
    21 22 23 24 25 26 27 28 29 30
    and so on .. can anybody help ?
    Think of a way to print numbers and look at what condition needs to be met so that a new line is printed.

  4. #4
    nikiiz is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default Re: how to make grid number ?

    I have try using this code but it don't work in java 2d

    for (int i=0; i <= 100; i++){
    System.out.print(i+" ");
    int mod = i % 10;
    if (mod == 0)
    System.out.print("\n");

    }

    or this

    for (int i=1; i <= 100; i++){
    int mod = i % 10;
    if (mod == 0);
    g2.drawString(i+"", x, y);
    }

    the problem is I don't know how to make it new line in java 2d
    if it's in a normal java it has work alraedy.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default Re: how to make grid number ?

    how to make it new line in java 2d
    If you are using the drawString() method to write the String at one y location (on a row), you need to change the y value to draw the next String below the previous String. Change the x value to write in the next column on the same row beside the last String.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: how to make grid number ?

    Quote Originally Posted by nikiiz View Post
    I have try using this code but it don't work in java 2d
    This has nothing to do with Java 2D (not java 2d) which is about drawing and manipulating geometrical figures and images.

    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    nikiiz is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default Re: how to make grid number ?

    thank you for your help .. I have found the solution to my problem :)

Similar Threads

  1. Open Grid Scheduler/Grid Engine
    By java software in forum Java Software
    Replies: 0
    Last Post: 03-27-2012, 08:00 PM
  2. Replies: 3
    Last Post: 03-23-2012, 08:43 PM
  3. creating a make grid method
    By Matt198525 in forum New To Java
    Replies: 13
    Last Post: 10-29-2010, 03:47 AM
  4. how do i make a string return a number?
    By pjr5043 in forum New To Java
    Replies: 6
    Last Post: 09-15-2008, 05:56 AM
  5. Will make a pyramid of some kind out of a number
    By romina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •