import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class Progress extends JFrame {
JProgressBar current;
JTextArea out; //这两个变量声明具体有什么用啊,我把它们都注释掉后了,程序执行的效果也一样的啊
JButton find; //同上
Thread runner;
int num=0;
public Progress() {
super("Progress");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane=new JPanel();
pane.setLayout(new FlowLayout()); //setLayout()方法有什么用,还有他里面的new FlowLayout是什么,有什么作用
current=new JProgressBar(0,2000);
current.setValue(0);
current.setStringPainted(true);
pane.add(current);
setContentPane(pane);
}
public void iterate() {
while (num<2000) {
current.setValue(num);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
//...
}
num+=95;
}
}
public static void main(String[] args) {
Progress frame=new Progress();
frame.pack();
frame.setVisible(true);
frame.iterate();
}
}问题已经提在注释里了,大家帮忙看看。
还有我已经查过API了,只是E文看不懂。
import java.awt.event.*;
import javax.swing.*;public class Progress extends JFrame {
JProgressBar current;
JTextArea out; //这两个变量声明具体有什么用啊,我把它们都注释掉后了,程序执行的效果也一样的啊
JButton find; //同上
Thread runner;
int num=0;
public Progress() {
super("Progress");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane=new JPanel();
pane.setLayout(new FlowLayout()); //setLayout()方法有什么用,还有他里面的new FlowLayout是什么,有什么作用
current=new JProgressBar(0,2000);
current.setValue(0);
current.setStringPainted(true);
pane.add(current);
setContentPane(pane);
}
public void iterate() {
while (num<2000) {
current.setValue(num);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
//...
}
num+=95;
}
}
public static void main(String[] args) {
Progress frame=new Progress();
frame.pack();
frame.setVisible(true);
frame.iterate();
}
}问题已经提在注释里了,大家帮忙看看。
还有我已经查过API了,只是E文看不懂。
解决方案 »
- Java ClassLoader机制引发的WinForm程序加载类的一些疑惑? 求解答
- 同步方法与同步某个对象的区别?
- java如何打开目录下特定文件
- java的一些小问题
- 放在JTable中的数据是不是只能是数组或vector???
- 使用getImage方法装载图像,但是不能显示,有时显示,会提示outofmemory的异常。如何解决
- 请教高手关于JAVA画图的控件(字体)方法问题...(给分..)
- 如何从SQL数据库中将类型为image的字段中的值取出来存为图片文件格式
- 帮帮我
- farawayzheng_necas(遥远)接分!
- 混淆器RetroGuard问题
- 问一个很简单的问题~~~~~~~~~~`
并没有实例化所以没有没并不影响到程序setLayout()是用来设置布局的
FlowLayout只是多种布局中的一种,还有BorderLayout,GridLayout等等