日期:2014-05-20 浏览次数:20811 次
final JFrame frame = new JFrame();
//MyLabel是重写了paint方法的Label
MyLabel stateLbl = new MyLabel(new ImageIcon(JFrame.class.getResource("/wait.gif")).getImage());
stateLbl.setVisible(true);
frame.setUndecorated(true);
frame.add(stateLbl,BorderLayout.CENTER);
//frame.setSize(200, 20);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setAlwaysOnTop(true);
frame.setVisible(true);
//Thread.sleep(10000);
final Thread mainTh = Thread.currentThread();
new Thread() {
public void run() {
try {
Thread.sleep(10000);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
frame.setVisible(false);
synchronized (mainTh) {
mainTh.notify();
}
}
}.start();
synchronized (mainTh) {
mainTh.wait();
}
BusyDialog bd = new BusyDialog();
ExecutorService executor = Executors
.newCachedThreadPool();
CountDownLatch latch = new CountDownLatch(1);
CopyWorker w1 = new CopyWorker(latch, "CopyWorker",
file, des);
LodingWorker loading = new LodingWorker(latch, bd);
executor.execute(w1);