Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 28-05-2009
Member
 
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();
}
}
}
Reply With Quote
  #2  
Old 28-05-2009
Member
 
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?
Reply With Quote
  #3  
Old 28-05-2009
Member
 
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.
Reply With Quote
  #4  
Old 29-05-2009
Member
 
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;
Reply With Quote
  #5  
Old 29-05-2009
Member
 
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.
Reply With Quote
  #6  
Old 30-05-2009
Member
 
Join Date: Feb 2009
Posts: 96
Re: updated code JAVA cant get it to erase now

got the program running thanx
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "updated code JAVA cant get it to erase now"
Thread Thread Starter Forum Replies Last Post
Zero-day vulnerability discovered in the latest updated version of Java racer Web News & Trends 1 28-08-2012 06:37 PM
help me to understand java code (calendar java code) ? so0oma Software Development 2 10-01-2011 12:01 AM
UPDATED: X360 Online Pass; Code Invalid or In Use. Flamingo-R Video Games 4 22-10-2010 03:44 AM
JAVA -- updated code Daren Software Development 1 21-09-2009 08:22 AM
Sun Java JRE 6 Update 14 updated with Win 7 compatibility Erubiel Windows x64 Edition 2 29-05-2009 07:52 AM


All times are GMT +5.5. The time now is 01:47 AM.