I'm trying to make the integer near "time left" to decrements by one and repaint every second but I can only see the changes when I resize the window constantly. I've tried this in Jcreator 3 in windows and in Ububtu 11.10 command line but it still doesn't work.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import javax.imageio.*;
class StatusPanel extends JPanel implements ActionListener {
int time = 60;
int round = 1;
Timer timer;
public StatusPanel() {
this.timer = new Timer(1000, this);
this.timer.start();
this.setVisible(true);
this.setDoubleBuffered(true);
}
public void updateTime() {
if (time > 0) {
time--;
}
}
public void paint(Graphics page) {
super.paint(page);
page.setFont(new Font("TimesRoman", Font.PLAIN, 30));
String sTime = String.valueOf(time);
String sRound = String.valueOf(round);
page.setColor(Color.WHITE);
page.drawString(sTime, 253, 149);
page.drawString(sRound, 230, 105);
}
public void actionPerformed(ActionEvent event) {
this.updateTime();
}
}