package ui.status;
import java.awt.BorderLayout;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JPanel;
import javax.swing.border.SoftBevelBorder;
public class FakeBar extends JPanel
{
private static final long serialVersionUID = 3384614949446196984L;
private class Animator extends TimerTask
{
private Timer timer;
public Animator()
{
timer = new Timer("Scheduler: fakebar animation");
timer.scheduleAtFixedRate(this, 0, 20);
}
public void run()
{
graphics.advanceCursor();
}
public void stop()
{
timer.cancel();
}
}
private boolean activated;
private FakeBarGraphics graphics;
private Animator animator;
public FakeBar()
{
super();
setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
setLayout(new BorderLayout());
setVisible(false);
activated = false;
graphics = new FakeBarGraphics();
add(graphics, BorderLayout.CENTER);
}
public void activate()
{
if (!activated)
{
animator = new Animator();
activated = true;
setVisible(true);
}
}
public void stop()
{
if (activated)
{
setVisible(false);
animator.stop();
animator = null;
activated = false;
repaint();
}
}
}