日期:2014-05-20 浏览次数:20750 次
private Timer timerFinished = new Timer(); private List allUrls = new ArrayList(); // 所有需要打开的url列表 private void openUrl(){ timerFinished = new Timer(); // 在1秒后执行此任务,每次间隔2秒,如果传递一个Data参数,就可以在某个固定的时间执行这个任务. timerFinished.schedule(new ListenSysOpenFinished(), 2000, 1000); } public class ListenSysOpenFinished extends TimerTask { @Override public void run() { oneByOneOpenSys(); } } public void oneByOneOpenSys() { if (allUrls.size() > 0) { timerFinished.cancel(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (allUrls.size() > 0) { String url = allUrls.get(0).toString(); NativeInterface.open(); NativeInterface.initialize(); // 显示日志信息 LoginLog loginLog = (LoginLog) curOpenSysInfo.get(0); if (loginLog.isClearCookie()) { JWebBrowser.clearSessionCookies(); } JPanel webBrowserPanel = new JPanel(new BorderLayout()); webBrowserPanel.setBorder(BorderFactory.createTitledBorder("KR-Browser")); webBrowser = new JWebBrowser(); webBrowser.navigate(url); webBrowserPanel.add(webBrowser); tbMain.addTab("browser", webBrowserPanel); webBrowser.addWebBrowserListener(new WebBrowserAdapter() { @Override public void loadingProgressChanged(WebBrowserEvent e) { if (e.getWebBrowser().getLoadingProgress() == 100) { JDate jDate = new JDate(); allUrls.remove(0); timerFinished = new Timer(); timerFinished.schedule(new ListenSysOpenFinished(), 1000, 2000); } } }); } } }); } else { timerFinished.cancel(); } }