简体   繁体   English

进度条 Java 退出

[英]Progress Bar Java exit

i am doing a quiz in java and i figured out everything except i want to put in a progressbar.I want to exit my actual frame(or to show something) when the progress bar is filled(i used it as a timer), how can i do it?我正在用 Java 做一个测验,除了我想放入进度条之外,我想出了所有内容。我想在进度条填满时退出我的实际框架(或显示某些内容)(我将其用作计时器),如何我可以做吗? I don't know how to do something when the bar is filled.当栏被填满时,我不知道该怎么做。 The code i have so far, it's a progress bar that fills for 30 secs or something very close to that.到目前为止,我拥有的代码是一个进度条,可以填充 30 秒或非常接近的时间。

al=new ActionListener(){
        public void actionPerformed(ActionEvent ae){
            if(jProgressBar1.getValue()<100){
                jProgressBar1.setValue(jProgressBar1.getValue()+5);
            }
            else{t.stop();}
        }
    };

    t=new Timer(1500,al);

Simple, put more code into this else{t.stop();} block.简单,将更多代码放入else{t.stop();}块中。 Here is where you would exit whatever it is you wish to exit.无论您想退出什么,您都可以在这里退出。

else {
    t.stop();
    // exit whatever window you wish to exit
}

Note that this is as about as detailed as we can go since you've not given more information about your current code.请注意,由于您没有提供有关当前代码的更多信息,因此我们尽可能详细。

Obligatory link: The Use of Multiple JFrames, Good/Bad Practice?强制性链接:使用多个 JFrame,好的/坏的做法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM