Hi folks. I'm new here so appologies if I'm not posting in the correct place. Here's my issue. I want to paint independent graphics on the same JPanel. I thought that I could create a method that paints my image(s) then call this in the constructor, but not sure what the arguments for the constructor should be. Example code below:
package myPaCKAGE;
import java.awt.Color;
import java.awt.Graphics;
public class image
{
private int width, height;
private Object square;
public Picture(int width, int height)
{
this.width = width;
this.height = height;
this.square();
}
}
public void square(Graphics g)
{
g.drawRect(10, 10,10, 10);
g.setColor(Color.red);
}
}
Problem lies with the line:
this.square();
as I'm not passing arguments to the method. What do I need to tell the constructor what the argument is in relation to the Graphics method?
Thanks in advance.
Jazzer