problem updating a drawnString
hey i have made a simple applet wich uses a timer to make a counter rise.
now all that works good, but the string keeps getting overwritten, so you can't actually read the numbers anymore... >.<
does anyone know how i can fix this?
this is the code wich is relevant i think
Code:
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.Timer;
public class Tellerpaneel extends JPanel
{
private Timer timer;
private int teller;
public Tellerpaneel()
{
teller =0;
timer = new Timer(100, new TimerHandler());
timer.start();
}
public void paintComponent(Graphics g)
{
super.paintComponents(g);
g.drawString("", 130, 80);
g.setColor(Color.BLUE);
g.setFont(new Font("SansSerif", Font.BOLD, 14));
g.drawString(String.format("Teller = %d",teller), 130,80);
}
class TimerHandler implements ActionListener
{
public void actionPerformed(ActionEvent arg0)
{
teller++;
repaint();
}
}
}
every help is appreciated.:)