【发布时间】:2011-03-28 04:34:47
【问题描述】:
所以当用户按下我的 JButton 时,它会选择一个随机时间,然后在该时间之后,它会在屏幕上绘制一个椭圆形。但是,就我现在所拥有的而言,它会在按下按钮后立即绘制椭圆形。我希望它在随机时间后出现。
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == startButton)
{
popUpTime = random.nextInt(5000);
timer = new Timer(popUpTime, this);
x = random.nextInt(400) + 70;
y = random.nextInt(400) + 100;
points[current++] = new Point(x, y);
timer.start();
start();
repaint();
}
}
【问题讨论】: