Drawn string (using drawString) flickers

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!

Answers


repaint();

Don't invoke repaint() from a painting method. You will cause an infinite loop.


Need Your Help

iOS - UITableView's superview covers the screen when app enters foreground

iphone ios uitableview superview

I have a UITableView that I am applying a set of filters on. The filters animate from below the navigation bar when I tap the "Filter" button. What I am doing here is taking a NIB that I loaded an ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.