So I created an abstract JPanel called BasePanel. In it I i use a double buffer code like so:
public void paint(Graphics g) {
dbImage = createImage(getWidth(), getHeight());
dbg = dbImage.getGraphics();
paintComponent(dbg);
g.drawImage(dbImage, 0, 0, this);
repaint();
}
public void paintComponent(Graphics g) {
g.setColor(Color.BLACK);
}
And then when extending it on another panel, i was wondering would it still double buffer if i only Overrode the paintComponent method? So I wouldnt even need to call the paint method
An Example
public class StartScreen extends BasePanel {
@Override
public void paintComponent(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.WHITE);
g.drawString("Animation Screen", 175, 150);;
repaint();
}
}
super.paintComponent(...)
Double buffering is automatically inherited from the parent component.