Having Trouble calling a class at different times - java

First off apologies for not being able to word my question accurately!
The problem I face is I have an array list with 4 classes that do the exact same thing , only that they need to be called at different times (when the first one's coordinate exceeds a certain value) but Im having trouble getting it done , and Cant find it online (probably because I cant word my questions accurately :/) anyway I will post my code below and if anyone could shed some light I would be extremely grateful!
**What im making is a a tunnel effect by connecting the center of the screen with each corner with lines, and now im attempting to simulate moving by starting lines coming from the middle of the screen towards the edge (starting with bottom portion) **
speedLines sline1, sline2, sline3, sline4;
// holds speedLines classes
ArrayList<speedLines> gameObject;
void setup() {
background(0);
size(750, 750);
smooth();
gameObject = new ArrayList<speedLines>();
sline1 = new speedLines(height/2);
sline2 = new speedLines(height/8);
sline3 = new speedLines(height/4);
sline4 = new speedLines((height/2)*3);
gameObject.add(sline1);
gameObject.add(sline2);
gameObject.add(sline3);
gameObject.add(sline4);
}
void draw() {
background(0);
for(int i=0; i< gameObject.size(); i++){
// go through the different classes
// 2 added so far
gameObject.get(i).display();
}
Guidelines();
}
//GLOBAL VARIABLES
int line=0;
int linewidth=0;
void Guidelines() {
stroke(255);
//MAIN GUIDE
line(0, 0, width/2, height/2);//top left guide
line(width, 0, width/2, height/2);//top right guide
line(0, height, width/2, height/2);//bottom left guide
line(width, height, width/2, height/2);//bottom right guide
//SUB GUIDE
stroke(60, 60, 60);
line(width/3, height, width/2, height/2);//sub guide left
line((width/3)*2, height, width/2, height/2);//sub guide right
}
class speedLines {
//Global variables
int Y;
speedLines(int y) {
}
void display() {
stroke(60, 60, 60);
line((width/2)-linewidth, (height/2)+line, (width/2)+linewidth, (height/2)+line);
line++;
linewidth++;
if ((height/2)+line >= height)
{
line=0;
linewidth=0;
}
}
}

If I were you, I would try to narrow this down to a smaller example sketch. I'd also try to clean up your code a bit: is there a reason you have sketch-level sline variables when you put them in the ArrayList anyway?
That being said, I'll try to help. You're passing a parameter into the speedLines class (which should really be called SpeedLine since classes should start with an upper-case letter and each instance only represents one line) constructor, but you're never using that parameter. Try to get it working with just one instance, like this:
Line myLine;
void setup() {
size(100, 500);
myLine = new Line(height/2);
}
void draw() {
background(200);
myLine.move();
myLine.render();
}
class Line {
float lineY;
public Line(float lineY) {
this.lineY = lineY;
}
public void move() {
lineY++;
if (lineY > height) {
lineY = 0;
}
}
public void render() {
line(0, lineY, width, lineY);
}
}
Notice how I'm actually using the lineY variable that I'm passing into my Line constructor. Try to get something like this working in your code. Then it'll be easier to use an ArrayList to draw multiple lines:
ArrayList<Line> myLines = new ArrayList<Line>();
void setup() {
size(100, 500);
for (float lineY = 0; lineY < height; lineY += 100) {
myLines.add(new Line(lineY));
}
}
void draw() {
background(200);
for (Line myLine : myLines) {
myLine.move();
myLine.render();
}
}
class Line {
float lineY;
public Line(float lineY) {
this.lineY = lineY;
}
public void move() {
lineY++;
if (lineY > height) {
lineY = 0;
}
}
public void render() {
line(0, lineY, width, lineY);
}
}
Also note that you're only ever really using a single value in your class (in my example, the lineY variable). So you probably don't really need a class to do this. You could probably do this with just an array of float values that hold the lineY values instead:
float[] lineY = new float[10];
void setup() {
size(100, 500);
for (int i = 0; i < lineY.length; i++) {
lineY[i] = i * 10;
}
}
void draw() {
background(200);
for (int i = 0; i < lineY.length; i++) {
lineY[i]++;
if (lineY[i] > height) {
lineY[i] = 0;
}
line(0, lineY[i], width, lineY[i]);
}
}
Please note that all of these are just examples, and you'll have to take these examples and understand what they're doing, then do similar things in your code. Good luck.

Related

I'm trying to create random object using arrays and class with random locations?

I'm trying to create a game using classes, in which objects move to random locations and use arrays in order to add up in a random amount. Can someone help me to code this better as it isn't working? I'm using the software "Processing" by the way.
My Code
My Class
*final color ALIEN_COLOR = color(30, 100, 0);
PImage background;
int x=0; //global variable background location
Superhero hero1;
Alien [] invader1 = new Alien[8];
void setup(){
size(800,400);
background = loadImage("spaceB.jpg");
background.resize(width,height);
hero1 = new Superhero(10, height/2);
for(int i = 0; i < invader1.length; i++){
invader1[i] = new Alien();
invader1 = new Alien(width,300);
}
} // setup ends
void draw ()
{
drawBackground();
hero1.render();
invader1.render();
if(invader1.move() == false){
invader1 = new Alien(width, 500);
}
} // draw ends*
and object as:
***class Alien{
int x;
int y;
Alien(int x, int y){
this.x = x;
this.y = y;
}
void render(){
fill(ALIEN_COLOR);
rect(x, y, 50, 50);
}
boolean move(){
x = x - 1;
return (x >= 0);
}
}***
The error messages that I received are:
the constructor Alien() doesn't exist.
mismatch, Defenders.Alien doesn't match Defenders.Alien[]
You are calling invader1[i] = new Alien(); but you do not have no-arg constructor in Alien class. Declare a no-arg constructor in Alien class as follows to get rid of the issue:
Alien() {
// Put here some initialization code if needed else leave it as it is
}

Objects sharing another object (Processing 3.3.7)

Hello Stack Overflow people :)
I'm a huge newbie when it comes to coding, and I've just ran into a problem that my brain just won't get over...
Before I start blabbering about this issue, I'll paste my code so as to give a little bit of context (sorry in advance if looking at it makes you wanna puke). The main focus of the issue is commented and should therefore be fairly visible :
Main
ArrayList<Individual> individuals = new ArrayList<Individual>();
void setup()
{
size(500,500);
for(int i = 0; i < 2; i++)
{
individuals.add(new Individual());
}
println(frameRate);
}
void draw()
{
background(230);
for(int i = 0; i < individuals.size(); i++)
{
individuals.get(i).move();
individuals.get(i).increaseTimers();
individuals.get(i).display();
}
}
Individual
class Individual
{
float x;
float y;
int size = 5;
Timer rdyBreed; /* Here is the object that appears to be shared
between individuals of the ArrayList */
float breedRate;
float breedLimit;
Individual()
{
x = random(0, width);
y = random(0, height);
rdyBreed = new Timer("rdyBreed", 0);
breedRate = random(.2, 3);
breedLimit = random(10, 20);
}
void move()
{
int i = (int)random(0, 1.999);
int j = (int)random(0, 1.999);
if (i == 0)
{
x = x + 1;
} else
{
x = x - 1;
}
if (j == 0)
{
y = y + 1;
} else
{
y = y - 1;
}
checkWalls();
}
void checkWalls()
{
if (x < size/2)
{
x = width - size/2;
}
if (x > width - size/2)
{
x = size/2;
}
if (y < size/2)
{
y = width - size/2;
}
if (y > width - size/2)
{
y = size/2;
}
}
void display()
{
noStroke();
if (!rdyBreed.finished)
{
fill(255, 0, 0);
} else
{
fill(0, 255, 0);
}
rect(x - size/2, y - size/2, size, size);
}
void increaseTimers()
{
updateBreedTimer();
}
void updateBreedTimer()
{
rdyBreed.increase(frameRate/1000);
rdyBreed.checkLimit(breedLimit);
rdyBreed.display(x, y);
}
}
Timer
class Timer
{
float t;
String name;
boolean finished = false;
Timer(String name, float t)
{
this.t = t;
this.name = name;
}
void increase(float step)
{
if (!finished)
{
t = t + step;
}
}
void checkLimit(float limit)
{
if (t >= limit)
{
t = 0;
finished = true;
}
}
void display(float x, float y)
{
textAlign(RIGHT);
textSize(12);
text(nf(t, 2, 1), x - 2, y - 2);
}
}
Now that that's done, let's get to my question.
Basically, I'm trying to create some sort of a personal Conway's Game of Life, and I'm encountering a lot of issues right off the bat.
Now my idea when writing this piece of code was that every individual making up the small simulated "society" would have different timers and values for different life events, like mating to have children for example.
Problem is, I'm not a huge pro at object-oriented programming, and I'm therefore quite clueless as to why the objects are not having each their own Timer but both a reference to the same timer.
I would guess making an ArrayList of timers and using polymorphism to my advantage could make a change, but I'm not really certain of it or really how to do it so... yeah, I need help.
Thanks in advance :)
EDIT : Here is a screenshot of the debugger. The values keep being the same with each iteration of the updates.
Screenshot
What makes you think they reference the same Timer object? The values of t displayed in the debugger are going to be the same until one of them reaches the breedLimit and gets set to 0, because they're being initialized at the same time.
Try this and see that the values of t are different.
void setup() {
size(500,500);
}
void mouseClicked() {
individuals.add(new Individual());
}
I'd recommend setting the breakpoint somewhere around here:
t = 0;
finished = true;
They do not share the same timer, you create a new Timer object for each Individual.
class Individual {
// ...
Timer rdyBreed;
Individual() {
// ...
rdyBreed = new Timer("rdyBreed", 0);
//...
The only way they could be sharing the same Timer is if you were setting rdyBreed elsewhere, but since you don't want that I recommend making it final.
If you did want to share the same Timer instance across all individuals then you could declare it static.

Processing / How to make selectable object, that moves where i click

that really sucks ... i know how to make classes, objects, interfaces, loops etc . But everytime i try to make a unit or more than one, that is moving (when i select it) to the point where i click i get errors, errors and errors .... Why the hell theres nowhere a tutorial for that ?
My new class looks so atm :
class Unit {
int X;
int Y;
int Breite;
int Laenge;
int ID;
boolean ausgewaelht = false;
Unit() {
}
Unit(int x, int y, int breite, int laenge) {
}
void create(UnitContent function) {
function.form();
}
void move(float geschwindigkeit) {
if(isTriggerd(X,Y,Breite,Laenge) == true){
X = X+(int)geschwindigkeit;
if(X > width) {
X = 0;
}
}
}
void setXandY(int x , int y) {
X = x;
Y = y;
}
void setBreiteandLaenge(int breite, int laenge) {
Breite = breite;
Laenge = laenge;
}
void setID(int id) {
ID = id;
}
int getX() {
return X;
}
int getY() {
return Y;
}
int getBreite() {
return Breite;
}
int getLaenge() {
return Laenge;
}
int getID() {
return ID;
}
boolean isTriggerd(int x, int y, int breite, int laenge) {
if(mouseX > x && mouseX < x+breite && mouseY > y && mouseY < y+laenge ) {
return true;
}
else {
return false;
}
}
}
IS there something i forgot ?
And how do i display 10 or 50 units of them?
sorry for my bad english :) and thx for your help
Some friendly advice: your tone comes off sounding a bit demanding, and your description is very vague. You'll have much better luck if you try to make it easy for other people to help you.
Tell us exactly what errors you're getting.
Post an MCVE with enough code so we can run it, but not any code that isn't directly related to your problem.
Try breaking your problem down into small steps, and only ask one specific question at a time.
Check out the question checklist and make sure you've done everything on the list.
Why the hell theres nowhere a tutorial for that ?
Keep in mind that the people answering questions on Stack Overflow are doing so for free, in their spare time. The people developing Processing are doing so for free, in their spare time. Even so, there are a ton of tutorials on your problems. Have you tried searching on google?
Here is a tutorial that does exactly what you're looking for. These examples come with the Processing editor (go to File -> Examples). The reference is another great resource that you should check out.
All of that being said, I'll walk you through solving this problem, and hopefully how to solve other problems in the future.
Step 0: Break your problem down into smaller steps. This is the golden rule of programming. Whenever you're stuck, go back to this step. This step fuels the rest of the steps, and it should be the first, second, and third thing you do whenever you're stuck.
Step 1: Can you draw a single object? Don't worry about interaction or multiple objects or anything else, just draw a single object. Get that code working first.
Here's code that draws a single circle:
void setup(){
size(500, 500);
ellipseMode(CENTER);
}
void draw(){
background(0);
ellipse(100, 200, 50, 50);
}
Step 2: Can you encapsulate the information needed to draw the object in a class? Again, only worry about the next small step- don't worry about multiple shapes yet. Just get a class working for a single object. Here is how we might encapsulate the data for our circle:
Circle circle;
void setup() {
size(500, 500);
ellipseMode(CENTER);
circle = new Circle(100, 200, 50);
}
void draw() {
background(0);
circle.draw();
}
class Circle {
float x;
float y;
float r;
public Circle(float x, float y, float r) {
this.x = x;
this.y = y;
this.r = r;
}
void draw() {
ellipse(x, y, r, r);
}
}
If you have trouble on this step, then you can post something like this small example with a more specific question, and it'll be much easier to help you than if you post a section of your entire sketch without any specific errors.
Step 3: Can you add some simple user interaction logic to your circle class? Don't worry about clicking yet, just try to change the color of the circle when you move your mouse over it.
Circle circle;
void setup() {
size(500, 500);
ellipseMode(RADIUS);
circle = new Circle(100, 200, 50);
}
void draw() {
background(0);
circle.draw();
}
class Circle {
float x;
float y;
float r;
public Circle(float x, float y, float r) {
this.x = x;
this.y = y;
this.r = r;
}
void draw() {
if(dist(mouseX, mouseY, x, y) < r){
//mouse is inside circle
fill(0, 255, 0);
}
else{
//mouse is outside circle
fill(0, 0, 255);
}
ellipse(x, y, r, r);
}
}
By breaking your bigger problem down into these smaller steps, it becomes much easier to debug your code than if you try to write your entire sketch at one time.
Step 4: Can you improve your interaction code to detect a click? Can you move the circle when a drag is detected?
You should probably break those steps down even further, but for the sake keeping this post short(er), I've combined them into one:
Circle circle;
void setup() {
size(500, 500);
ellipseMode(RADIUS);
circle = new Circle(100, 200, 50);
}
void draw() {
background(0);
circle.draw();
}
class Circle {
float x;
float y;
float r;
public Circle(float x, float y, float r) {
this.x = x;
this.y = y;
this.r = r;
}
void draw() {
if(dist(mouseX, mouseY, x, y) < r){
//mouse is inside circle
if(mousePressed){
//mouse is being dragged
fill(255, 0, 0);
//move the circle to the mouse position
x = mouseX;
y = mouseY;
}
else{
//mouse is not clicked
fill(0, 255, 0);
}
}
else{
//mouse is outside circle
fill(0, 0, 255);
}
ellipse(x, y, r, r);
}
}
Step 5: Can you make it work for multiple objects? If you've done a good job of breaking your problem down into small steps and encapsulating your logic into a class, then this step becomes pretty easy.
ArrayList<Circle> circles = new ArrayList<Circle>();
void setup() {
size(500, 500);
ellipseMode(RADIUS);
for (int i = 0; i < 10; i++) {
circles.add(new Circle(random(width), random(height), random(10, 50)));
}
}
void draw() {
background(0);
for (Circle circle : circles) {
circle.draw();
}
}
class Circle {
float x;
float y;
float r;
public Circle(float x, float y, float r) {
this.x = x;
this.y = y;
this.r = r;
}
void draw() {
if (dist(mouseX, mouseY, x, y) < r) {
//mouse is inside circle
if (mousePressed) {
//mouse is being dragged
fill(255, 0, 0);
//move the circle to the mouse position
x = mouseX;
y = mouseY;
} else {
//mouse is not clicked
fill(0, 255, 0);
}
} else {
//mouse is outside circle
fill(0, 0, 255);
}
ellipse(x, y, r, r);
}
}
To summarize, you need to break your problem down into smaller steps and take on those steps one at a time. If you get stuck on a specific step (or if you don't understand one of the steps in my answer) then you can post a small example MCVE like my examples above, and ask a specific question.
Happy coding!
It really doesn't look like you have any graphical code except for some coordinates. In order to display something in Java you have to use a library that supports it like Swing or JavaFX. Here's a SO question that will give you some idea of what the differences are. Happy coding!

How to repaint over images in Java game

Hello everyone I am having trouble with painting over coins that the user intersects with. What I want this code to do is when the user sprite intersects with any of the ten coin images it paints over the coin so that it no longer appears on the screen (also need to add in some kind of counter so that when the user collects all ten coins it will stop the thread, and say "You Win!"). My question is how would I go about doing this because I have tried using repaint() in the if statements, and it is not compiling correctly anymore. Any help on how to paint over the coins, and possibly even add some kind of counter (thinking a for loop would come in handy) would be greatly appreciated! Here is the code:
public void paint(Graphics g)
{
g.clearRect(0, 0, this.getWidth(), this.getHeight());
one.paintComponent(g);
two.paintComponent(g);
three.paintComponent(g);
four.paintComponent(g);
five.paintComponent(g);
six.paintComponent(g);
seven.paintComponent(g);
eight.paintComponent(g);
nine.paintComponent(g);
ten.paintComponent(g);
monster.setLocation(r.nextInt(10) - 5 + monster.x, r.nextInt(10 - 5 + monster.y));
monster.paintComponent(g);
user.paintComponent(g);
if(user.intersects(one))
{
}
if(user.intersects(two))
{
}
if(user.intersects(three))
{
}
if(user.intersects(four))
{
}
if(user.intersects(five))
{
}
if(user.intersects(six))
{
}
if(user.intersects(seven))
{
}
if(user.intersects(eight))
{
}
if(user.intersects(nine))
{
}
if(user.intersects(ten))
{
}
if(user.intersects(monster))
{
g.setFont(new Font("Serif", Font.BOLD, 35));
g.drawString("YOU HAVE DIED, YOU LOSE!", 100, 100); //Prints this when you lose
thread.interrupt(); //Stopping the thread if you die
}
}
At first, you should put the coins in a list. Then, if there's an interection, you simply remove the item (coin) of the list. Like this:
private List<Coin> coins;
public ClassConstructor() {
coins = new ArrayList();
coins.add(new Coin(type value,...)); //this ten times if every Coin is different from other
//or this if every Coin are same:
for (int i = 0; i < 10; i++) {
coins.add(new Coin(type value,...));
}
}
public void update() {
//whatever
for (int i = coins.size(); i >= 0; i--) {
if (user.intersects(coins.get(i))) {
coins.remove(i);
//...
}
}
}
public void paint(Graphics g) {
for (int i = coins.size(); i >= 0; i--) {
coins.get(i).paintComponent(g);
}
}
Now, you shouldnt end a Thread with thread.interrupt(). If that thread is your game loop, you should send a flag that ends the loop. The Thread of you game loop:
#Override
public void run() {
while (running) { //boolean running
update();
paint(g);
}}
And, finally, your update will be like:
public void update() {
//whatever
for (int i = coins.size(); i >= 0; i--) {
if (user.intersects(coins.get(i))) {
coins.remove(i);
//...
}
}
if (user.intersects(monster)) {
youThread.setRunning(false);
try {
gameLoopThread.join(); //"wait" until thread ends
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
This code is taken from my current project (that is working), I tried adjusting it to your project.
private void render () {
BufferStrategy bufferstrategy = getBufferStrategy ();
if (bufferstrategy == null) {
createBufferStrategy(3);
return;
}
Graphics g = bufferstrategy.getDrawGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
paint (g);
g.dispose();
bufferstrategy.show();
}
render() is called from run(), where the Thread is.
Let's break it down and see if it can help you.
It gets a BufferStrategy for how many images to have ready. It can be set to anything like you like within reason. 2 - 4 will do the trick. One can even work.
It sets your current BufferStrategy to your Graphics.
It then fills the screen with the color of white (could be a clear as well).
Then it paints all components, in your case it calls paint (Graphics g) while in my case it iterates through all drawable objects.
It re-renders everything as it now should look.
Hope you take some points out from this.
Off the top of my head, put while(true) within your Run() method (you said you were using a thread) and call repaint() within the loop, at the end of the loop (within a try/catch) put something like //thread//.sleep(allotted time) This will stop the thread for the set amount of Milliseconds. Within the Javadoc of repaint() you'll see that it calls the nearest paint(Graphics g) method. By doing this you can access your paint() method from wherever you are in your program.
My suggestion to the coin's is make it it's own class. The class would look similar to this:
public class Coin{
int x;
int y;
public void Coin(int x, int y, Graphics g){
Graphics2D g2 = (Graphics2D) g;
Image img1 = (//File Location);
g2.drawImage(img1, x, y, //this);
//If you have trouble with the ImageObserver (this part) try //class name of the applet.this
this.x = x;
this.y = y;
g2.finalize();
}
public int getX(){
return x;
}
public int getY(){
return y;
}
}
After that, in your paint method you could make 10 Coin objects and use g which you instantiate in the parameters. You could then make an array of Coin objects and add 10 Coins that you make in your paint method manually (yeah, it's a pain) (you have to make them in paint to pass the Graphics variable)
Coin[] coins = new Coin[10];
Is how you make the array, by the way. After you make the array of coin's, then make a for loop in your paint method. It should look something like this:
for(int i = 0; i < coins.length; i++){
if(coins[i].getX == //user X && coins[i].getY == //user Y){
g.clearRect(coins[i].getX, coins[i].getY, //Coin radius, //Coin radius);
}
}
This will make a clear rectangle be drawn over wherever the Coin is at if the user's X and Y is equal to the Coin's X and Y.

Java program not running correctly on MAC

I have recently started using a mac to develop on and i am having a strange problem.
Take the Program below:
public class Driver {
public static void main(String [ ] args) {
SolarSystem SSpanel = new SolarSystem(600, 600);
SSpanel.drawSolarObject(0, 0, 30, "YELLOW");
}
}
the SolarSystem class extends JFrame and basically when the new SolarSystem is created it makes a panel of that size.
the drawSolarObjects basically draws a circle of a certain colour and size. finishedDrawing actually makes the object appear on the panel.
The example above does work but I have more complex requirements which involve putting this into a while loop.
this is where it gets weird, if i run the below program with cmd on a windows computer it works fine and prints the yellow circle to the screen. On my mac, adding this while loop causes it to just create the panel but not paint the yellow circle.
public class Driver{
public static void main(String [ ] args) {
boolean oMove = true;
SolarSystem SSpanel = new SolarSystem(600, 600);
while(oMove){
SSpanel.drawSolarObject(0, 0, 30, "YELLOW");
SSpanel.finishedDrawing();
}
}
}
I put a print into my loop to check it was running through it and that showed that it was definitely running through the loop.
Does anyone know what could be causing this?
Ive am adding the functions so you can get a better picture
SolarSystem Constructer:
public SolarSystem(int width, int height)
{
this.width = width;
this.height = height;
this.setTitle("The Solar System");
this.setSize(width, height);
this.setBackground(Color.BLACK);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
drawSolarObject Function:
public void drawSolarObject(double distance, double angle, double diameter, String col)
{
Color colour = this.getColourFromString(col);
double centreOfRotationX = ((double) width) / 2.0;
double centreOfRotationY = ((double) height) / 2.0;
double rads = Math.toRadians(angle);
double x = (int) (centreOfRotationX + distance * Math.sin(rads)) - diameter / 2;
double y = (int) (centreOfRotationY + distance * Math.cos(rads)) - diameter / 2;
synchronized (this)
{
if (things.size() > 1000)
{
System.out.println("\n\n");
System.out.println(" ********************************************************* ");
System.out.println(" ***** Only 1000 Entities Supported per Solar System ***** ");
System.out.println(" ********************************************************* ");
System.out.println("\n\n");
this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
else
{
SolarObject t = new SolarObject((int)x, (int)y, (int)diameter, colour);
things.add(t);
}
}
}
finishedDrawing function:
public void finishedDrawing()
{
try
{
this.repaint();
Thread.sleep(30);
}
catch (Exception e) { }
synchronized (this)
{
things.clear();
}
}
This all works fine on a windows PC
Your code risks tying up the Swing event thread preventing it from drawing on your GUI, and effectively freezing your program. Instead use a Swing Timer, not a while loop to achieve your goal.
e.g.,
final SolarSystem SSpanel = new SolarSystem(600, 600);
int timerDelay = 100;
new Timer(timerDelay, new ActionListener() {
public void actionPerformed(ActionEvent e) {
// do repeated action in here
}
}).start();
As an aside, I was going to place,
SSpanel.drawSolarObject(0, 0, 30, "YELLOW");
SSpanel.finishedDrawing();
inside my timer code, but it wouldn't make sense because this code isn't "dynamic" and doesn't change anything or do any animation.

Categories

Resources