What is the best way to double buffer in this case and how to do it....
currently I have
public class Frame1 extends JFrame{
}
I am making a "paint" program, and I have individual classes to handle the paint methods heres an example:
<b>
abstract public class Shape {
public Shape() {
}
public abstract void draw(Graphics g, Color c, int x, int y, int width,int height);
}</b>
and then....
public class Circle extends Shape{
public Circle() {
}
public void draw(Graphics g, Color c, int oldx, int oldy, int newx, int newy) {
g.setColor(c);
g.drawOval(Math.min(oldx, newx), Math.min(oldy, newy), Math.abs(oldx - newx), Math.abs(oldy - newy));
}
}
There is also a Rectangle class, line class.... etc! So my question to you is the following... what is the best way to implement double buffer in the individual classes? And how to do it?? And also.... the drawings should be kept inside a jPanel.
<b>Any bit of help</b> is much appreciated Thank you!!
currently I have
public class Frame1 extends JFrame{
}
I am making a "paint" program, and I have individual classes to handle the paint methods heres an example:
<b>
abstract public class Shape {
public Shape() {
}
public abstract void draw(Graphics g, Color c, int x, int y, int width,int height);
}</b>
and then....
public class Circle extends Shape{
public Circle() {
}
public void draw(Graphics g, Color c, int oldx, int oldy, int newx, int newy) {
g.setColor(c);
g.drawOval(Math.min(oldx, newx), Math.min(oldy, newy), Math.abs(oldx - newx), Math.abs(oldy - newy));
}
}
There is also a Rectangle class, line class.... etc! So my question to you is the following... what is the best way to implement double buffer in the individual classes? And how to do it?? And also.... the drawings should be kept inside a jPanel.
<b>Any bit of help</b> is much appreciated Thank you!!