Results 1 to 2 of 2
  1. #1
    Bader is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default change text colors through nested loop

    Hello

    I have like a table to make a nested loop in Java applet , during this loop i should change the colors like the picture said.

    now i successed to make the table but i cannot change the colors because every time i try a forumla , it doesn't work.

    Here is my code

    Java Code:
    int x = 63;
    
      for (int r=1; r<=10;r++)
      {
    
       Color C = new Color(0,10 +(x * 2),0);
    
       for (int c=0; c<=4; c++)
       {
    
       Color C2 = new Color(10 + (x * 2) ,0,0);
       g.setColor(C2);
       Font F = new Font("Arial",Font.BOLD, 24);
       g.setFont(F);
       g.drawString("Hello",10 + ( c * 60), r * 25 );
    
       }
      }


    i need to do it like this one ,what should i do to make it work ?

  2. #2
    Bader is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    for (int r=1; r<=10;r++)
    {


    for (int c=1; c<=5; c++)
    {

    Color C2 = new Color(0 + (r * 25) ,0 +(c * 51),0);
    g.setColor(C2);
    Font F = new Font("Times New Roman",Font.BOLD, 24);
    g.setFont(F);
    g.drawString("Hello",10 + ( c * 60), r * 25 );

    }
    }

    thanks , it worked now :)

Similar Threads

  1. Nested Loop help -- concerning image repetition
    By Submerged in forum Java Applets
    Replies: 0
    Last Post: 03-05-2010, 03:57 AM
  2. can some one help me with nested loop?
    By keycoffee in forum New To Java
    Replies: 10
    Last Post: 01-25-2010, 02:49 AM
  3. nested for loop question
    By javabob in forum New To Java
    Replies: 3
    Last Post: 05-20-2008, 11:00 PM
  4. change colors
    By calblue in forum New To Java
    Replies: 1
    Last Post: 12-02-2007, 11:52 PM
  5. Nested For Loop
    By yuchuang in forum New To Java
    Replies: 1
    Last Post: 07-08-2007, 01:11 PM

Tags for this Thread

Posting Permissions

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