Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to double buffer with this scenario.....

Status
Not open for further replies.

seiya1994

Programmer
Apr 1, 2006
3
US
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!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top