Results 1 to 6 of 6

Thread: updated code JAVA cant get it to erase now

  1. #1
    Join Date
    Feb 2009
    Posts
    96

    updated code JAVA cant get it to erase now

    this link is what i want it to do:

    http://kucourses.com/ec/courses/2472...testyoyos.html


    this is the code i have






    import java.awt.;
    import java.applet.;

    public class YoYo extends Applet //make the class
    {
    private int ind = 0;
    private int x = 20;
    private int y = 20;
    int[] hor = { 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60};
    int[] vert = { 40,90, 100, 110, 120, 130, 140, 150, 160, 170, 180};
    int[] cHor = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50};

    private int sleep = 100;

    public void start()
    {
    ind = 0;
    }
    public void paint(Graphics gr)
    {
    boolean backwards = false;
    while(true)
    {
    if (ind==hor.length) backwards = true;
    if (ind==0) backwards = false;
    if (backwards) --ind ;
    else ++ind;


    gr.setColor(getBackground());
    gr.drawLine(60, 40, hor[ind], vert[ind]);
    gr.fillOval(cHor[ind], vert[ind],x, y);


    gr.setColor(Color.BLACK);
    gr.drawLine(60, 40, hor[ind], vert[ind]);
    gr.setColor(Color.GREEN);
    gr.fillOval(cHor[ind], vert[ind],x, y);


    try
    {
    Thread.sleep(sleep);
    }
    catch(InterruptedException e)
    {
    }
    repaint();
    }
    }
    }

  2. #2
    Join Date
    Jul 2004
    Posts
    153

    Re: updated code JAVA cant get it to erase now

    Can you please explain what exactly you want to do?
    The link you have provided is not working.
    Please elaborate what you want to do with your applet?

  3. #3
    Join Date
    Feb 2009
    Posts
    96

    Re: updated code JAVA cant get it to erase now

    I want the app to run like a yoyo by going down a string and up a string without having to reset the downward motion to 0 at the index to get it back to the top.

  4. #4
    Join Date
    Mar 2008
    Posts
    258

    Re: updated code JAVA cant get it to erase now

    Daren in the above given code I suppose you have forgot to declare the colour variable that you needs to declare, when you will declare that you will be able to access the the colour code in your program:

    Here i will give you an example about how to declare it.

    Code:
         Color redColor;
         Color weirdColor;
         Color bgColor;
    
    // Standard colors can be named like this
              redColor = Color.red;
    
      // lesser known colors can be made with R(ed)G(reen)B(lue).
              weirdColor = new Color(60,60,122);
    
              bgColor = Color.blue;

  5. #5
    Join Date
    Feb 2009
    Posts
    96

    Re: updated code JAVA cant get it to erase now

    my colors work fine i need it to go backwards.

  6. #6
    Join Date
    Feb 2009
    Posts
    96

    Re: updated code JAVA cant get it to erase now

    got the program running thanx

Similar Threads

  1. Replies: 1
    Last Post: 28-08-2012, 06:37 PM
  2. help me to understand java code (calendar java code) ?
    By so0oma in forum Software Development
    Replies: 2
    Last Post: 10-01-2011, 12:01 AM
  3. UPDATED: X360 Online Pass; Code Invalid or In Use.
    By Flamingo-R in forum Video Games
    Replies: 4
    Last Post: 22-10-2010, 03:44 AM
  4. JAVA -- updated code
    By Daren in forum Software Development
    Replies: 1
    Last Post: 21-09-2009, 08:22 AM
  5. Sun Java JRE 6 Update 14 updated with Win 7 compatibility
    By Erubiel in forum Windows x64 Edition
    Replies: 2
    Last Post: 29-05-2009, 07:52 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,231,501.36410 seconds with 17 queries