首页 \ 问答 \ 如何使用摆动计时器来延迟加载进度条(How to use the Swing Timer to delay the loading of a progress bar)

如何使用摆动计时器来延迟加载进度条(How to use the Swing Timer to delay the loading of a progress bar)

我需要找到一种使用进度条的Swing Timer的方法。 我尝试使用Thread.sleep(),但它使应用程序崩溃时。 任何使用Swing Timer而不是Sleep()的方法?

public void piiEros(int dist)
{
    Pii pii = new Pii();
    pii.setVisible(true);
    for(int pc = 0;100 > pc; pc++)
    {
        try {
            Thread.sleep(dist/100);
        } catch (InterruptedException ex) {
            Logger.getLogger(Trav.class.getName()).log(Level.SEVERE, null, ex);
        }
        pii.pg.setValue(pc);
    }
    pii.dispose();
    o.Eros();
}

注意:Pii是带有进度条的课程。 Dist是它加载的速度。 Trav是该方法所在的类.Pc代表%,在酒吧显示的内容多少。 o.Eros打开另一个GUI。


I need to find a way to use the Swing Timer with a progress bar. I tried using Thread.sleep(), but it crashed the app when I used it. Any ways to use the Swing Timer instead of the Sleep()?

public void piiEros(int dist)
{
    Pii pii = new Pii();
    pii.setVisible(true);
    for(int pc = 0;100 > pc; pc++)
    {
        try {
            Thread.sleep(dist/100);
        } catch (InterruptedException ex) {
            Logger.getLogger(Trav.class.getName()).log(Level.SEVERE, null, ex);
        }
        pii.pg.setValue(pc);
    }
    pii.dispose();
    o.Eros();
}

NOTES: Pii is a class with th Progress Bar. Dist is the speed at which it loads. Trav is the class the method is in. Pc stands for %, how much is done is displyed on the bar. o.Eros opens anotherr GUI.


原文:https://stackoverflow.com/questions/15668715
更新时间:2022-01-05 06:01

最满意答案

尝试这个:

Config::set('database.fetch', PDO::FETCH_ASSOC);

$pools = DB::table('addresses as a')
        ->join('incodes as i', 'i.id', '=', 'a.incode_id')
        ->join('draws as d', 'd.incode_id', '=', 'i.id')
        ->join('users as u', 'u.id', '=', 'a.user_id')
        ->where('d.isactive', '=', '1')
        ->select('u.id as user_id', 'd.id as draw_id')
        ->distinct()
        ->get();

Pool::insert($pools);

foreach ($pools as $pool) {
    if ($draw = Draw::find($pool['draw_id'])) {
        $draw->isactive = 0;
        $draw->save();
    }
}

Try this:

Config::set('database.fetch', PDO::FETCH_ASSOC);

$pools = DB::table('addresses as a')
        ->join('incodes as i', 'i.id', '=', 'a.incode_id')
        ->join('draws as d', 'd.incode_id', '=', 'i.id')
        ->join('users as u', 'u.id', '=', 'a.user_id')
        ->where('d.isactive', '=', '1')
        ->select('u.id as user_id', 'd.id as draw_id')
        ->distinct()
        ->get();

Pool::insert($pools);

foreach ($pools as $pool) {
    if ($draw = Draw::find($pool['draw_id'])) {
        $draw->isactive = 0;
        $draw->save();
    }
}

相关问答

更多