Expand|Select|Wrap|Line Numbers
- public void paint(Graphics g) {
- Rectangle r = getBounds();
- g.setColor(c);
- g.fillRect(0, 0, (int)r.getWidth(), (int)r.getHeight());
- }
Expand|Select|Wrap|Line Numbers
- public void paint(Graphics g) {
- g.drawImage(image, getX(), getY(), this);
- }
Expand|Select|Wrap|Line Numbers
- BufferedImage image;
- try {
- String path = "images/spaceship.png";
- URL url = getClass().getResource(path);
- image = ImageIO.read(url);
- }
- catch (IOException e)
- {
- System.out.println("not valid image");
- }
I'm also not sure if I should use a BufferedImage or a normal Image to construct my image, and what the best way to construct it would be.
Any help would be appreciated, thanks.