Hey i am still having trouble if you or anyone could possibly take a look at my code and help figure out my problem id really appreciate it:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class BlockAnimation extends JPanel {
Image image; // Declare a name for the Image object.
Image image1;
Image image2;
Image image3;
Timer pptimer;
Rectangle rect;
int x = 30;
int x1 = 50;
int y;
int y1;
// Rectangle rect;
int bounds;
public BlockAnimation() {
super();
// Load an image file into the Image object. This file has to be in the same folder
image = Toolkit.getDefaultToolkit().getImage("block_yellow.png");
image1 = Toolkit.getDefaultToolkit().getImage("block_blue.png");
image2 = Toolkit.getDefaultToolkit().getImage("block_green.png");
image3 = Toolkit.getDefaultToolkit().getImage("block_red.png");
setBorder(BorderFactory.createLineBorder(Color.black));
pptimer = new Timer(100, new TimerAction());
//rect = new Rectangle(0,0,200,500);
pptimer.start();
}
public void setAnimation(boolean OnandOff) {
if (OnandOff) {
pptimer.start();
} else {
pptimer.stop();
}
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
// Draw our Image object.
//g.drawImage(image,30,30,30,30, this);
g.drawImage(image,x,y,this);
// g.drawImage(image1,x1,y1, this);
//g.drawImage(image2,x,y, this);
//g.drawImage(image3,x,y, this);
}
class TimerAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
// if((y + x) == JFrame.HEIGHT)
// bounds = true;
// repaint();
}
}
}//endclass