How would someone call the paintComponent method?
As an exercise from one of my university course, I must call the paintComponent method later on in my code (after the object as been created).
Any hints? Sorry for my noobness, im still learning ;)
public class testPanel extends JPanel {
private testModel testModelHandle;
private Color[] colors;
public testPanel(testModel testModel) {
if (testModel == null)
throw new IllegalArgumentException("Should provide a valid instance of testModel!");
this.testModelHandle = testModel;
initializeColors();
}
private void initializeColors() {
// Some tile colours in the '0xRRGGBB' format
String[] testColorCodes = new String[]{
"0x89CFF0", "0xF4C2C2", "0xFFBF00", "0xFBCEB1",
"0x6495ED", "0x9BDDFF", "0xFBEC5D", "0xFF7F50",
"0x00FFFF", "0x98777B", "0x99BADD", "0x654321"
};
colors = new Color[testColorCodes.length];
for (int i = 0; i < colors.length; ++i)
colors[i] = Color.decode(testColorCodes[i]);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
//other stuff
}
}