ildg
发贴: 12
积分: 0
|
于 2005-02-09 10:35
楼主的这个popup类写得很好,赞一个。 关于关闭的时候会发生异常, 需要添加几句检验shell或者display是否被释放了: public void run() {
Display display = shell.getDisplay(); while (true) { try { Thread.sleep(10); if ((downPosition - moveStep) > upPosition) { if (!display.isDisposed()) //添加此句 display.syncExec(new Runnable() { public void run() { if (!shell.isDisposed()) //此处添加 shell.setLocation(leftPosition, downPosition - moveStep); downPosition -= moveStep; } }); } else { Thread.sleep(5000); if (!display.isDisposed()) //此处添加 display.syncExec(new Runnable() { public void run() { if (!shell.isDisposed()) //此处添加 shell.dispose(); } }); } } catch (InterruptedException e) { e.printStackTrace(); } }
|