Reputation: 257
I'm doing this project here, and I have to draw a string to prevent me some problems, the drawing works and the string updates just fine, thing is, it tends to flicker somehow. It's like it's being redrawn, and while it's acceptable to think that it needs to be redrawn due to how the values change, I'm pretty sure that it's not that idea that I can it 'flicker' as it is drawn once more.
Here's the code concerning the drawing of the string:
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.BLACK);
g.drawString("Arca: " + administrador.getCiudad().getArca()
+ " "
+ " Puntos de Belleza: " + administrador.getCiudad().getPuntosBelleza() +
" " +
" Habitantes: " +
administrador.getCiudad().getCantidadHabitantes() + " / "
+ administrador.getCiudad().getCantidadHabitantesDisponibles(), 400, 45);
repaint();
}
If you need any more information just tell me and I'll give it to you!
Upvotes: 0
Views: 424
Reputation: 324118
repaint();
Don't invoke repaint() from a painting method. You will cause an infinite loop.
Upvotes: 4