如何做一个加载的条啊? 有时候数据太多了。想做一个小面板,上面一个进度条,数据加载中加载完了关闭。不知道怎么实现啊~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JProgressBar;public class TestMain extends JFrame { private JButton button = null; private ProgressDialog dialog = null; public TestMain(){ super("Test"); button = new JButton("Start"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog = new ProgressDialog(); } }); this.getContentPane().setLayout(new FlowLayout()); this.getContentPane().add(button); this.setSize(300, 200); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } public static void main(String [] args){ new TestMain(); } class ProgressDialog extends JDialog implements Runnable { private JProgressBar pb = null; private Thread thread = null; public ProgressDialog(){ super(TestMain.this, "Loading...", true); thread = new Thread(this); pb = new JProgressBar(); pb.setMaximum(100); this.getContentPane().setLayout(new FlowLayout()); this.getContentPane().add(pb); this.setSize(200, 65); this.setLocationRelativeTo(TestMain.this); thread.start(); this.setVisible(true); } public void run(){ pb.setValue(0); for(int i = 0; i < 100; i++){ pb.setValue(i + 1); System.out.println(i); try { Thread.sleep(20); } catch (InterruptedException ex) { ex.printStackTrace(); } } } } } 关于整数相除问题,要求结果用整数或者是分数表示,不能用小数。。。求思路 csdn显示文本时如何解析[b][i]..[/b][/i]等字符的 一个很难的sql语句大求助 POI, 操作[.xls]文件, 怎么在指定位置,插入一个新行 工具的选择..(菜鸟哦) 如何在实现当鼠标移动到JLabel上面JLabel上面的文字添加一条下划线? 再论String s = "",new String(),new String("") 怎么将类序列化 请求http页面没有反应? 请教高手!急!如何用java程序在链接中打开excel或word文档 Orz Orz 高手请进
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JProgressBar;public class TestMain extends JFrame {
private JButton button = null;
private ProgressDialog dialog = null;
public TestMain(){
super("Test");
button = new JButton("Start");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog = new ProgressDialog();
}
});
this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(button);
this.setSize(300, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String [] args){
new TestMain();
}
class ProgressDialog extends JDialog implements Runnable {
private JProgressBar pb = null;
private Thread thread = null;
public ProgressDialog(){
super(TestMain.this, "Loading...", true);
thread = new Thread(this);
pb = new JProgressBar();
pb.setMaximum(100);
this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(pb);
this.setSize(200, 65);
this.setLocationRelativeTo(TestMain.this);
thread.start();
this.setVisible(true);
}
public void run(){
pb.setValue(0);
for(int i = 0; i < 100; i++){
pb.setValue(i + 1);
System.out.println(i);
try {
Thread.sleep(20);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
}
}