Thank's for the tutorial link, I'll go through it and see what I can learn.
--- Update ---
Edit: I managed to get it working and finish the assignment after a bit more googling and a lot of trial/error. Thanks a lot for the help Norm.
Just in case anyone found this page while googling for something here is the code that I ended up with.
import java.applet.Applet;
import java.awt.*;
public class AssignmentJ13PartFour extends Applet implements Runnable
{
String [] stringArray = new String[5]; //Creates a string array. NOTE: The rows and columns must be 1 number higher than you will use.
int xPos = 150; //Used to manipulate the X coords of the displayed string.
int yPos = -10; //Used to manipulate the Y coords of the displayed string.
int tempVariable = 0; //Controls which string in the array will be used.
int tempVariable2 = 0; //Controls the text color.
boolean tempBoolean = false; //If false then the string won't move on the X axis, if true then it won't move on the Y axis.
Thread threadRunner;
public void init()
{
setBackground(Color.black);
stringArray[0] = "Kiseki No Umi";
stringArray[1] = "Suffocated";
stringArray[2] = "Neon Pegasus";
stringArray[3] = "Happy Little Clouds";
stringArray[4] = "Garden of Your Mind";
}
public void paint(Graphics gr)
{
System.out.println("Test!");
if (tempVariable2 == 0)
gr.setColor(Color.white);
else if (tempVariable2 == 1)
gr.setColor(Color.red);
else if (tempVariable2 == 2)
gr.setColor(Color.green);
else if (tempVariable2 == 3)
gr.setColor(Color.blue);
else if (tempVariable2 == 4)
gr.setColor(Color.yellow);
gr.clearRect(0, 0, getWidth(), getHeight());
gr.drawString(stringArray[tempVariable], xPos, yPos); //What the string says, X coords, Y Coords.
}
public void start() //Starts the thread. NOTE: Must be named start.
{
if(threadRunner == null)
{
threadRunner = new Thread(this);
threadRunner.start();
}
}
public void run() //NOTE: Must be named run or an error occurs upon compiling.
{
while(true)
{
if (tempBoolean == false)
yPos = (yPos + 10);
else
xPos = (xPos + 10);
System.out.println("xPos is: "+xPos+" and yPos is:"+yPos+"");
if (xPos >= 400) //When the song title reaches this far off screen spot then this will change the string being displayed and the color in preparation for the next string, it also re-sets the X and Y coord variables.
{
tempVariable ++;
tempVariable2 ++;
xPos = 150;
yPos = -10;
tempBoolean = false;
}
if (yPos == 150) //When the string reaches the yPos of 150 then the direction changes and it moves to the right.
tempBoolean = true;
if ( (tempVariable == 5) && (tempVariable == 5) ) //Resets everything so the applet can seemlessly re-play forever.
{
tempVariable = 0;
tempVariable2 = 0;
xPos = 150;
yPos = -10;
}
repaint(); //Calls the paint() method, this is the ONLY way to do it as far as I know atm.
try {threadRunner.sleep(100);}
catch (InterruptedException e) {}
}
}
}