Each Browser instance is running in a separate native process where the web page is rendered. Sometimes this process can exit unexpectedly because of the crash in plugin. To receive notifications about unexpected render process termination you can use RenderListener. When you receive notification about render process termination you can display a "sad" icon like Google Chrome does, for example, to inform the user that this particular Browser component has crashed.(每个浏览器实例都在一个单独的本地进程中运行,在该进程中呈现网页。有时由于插件崩溃,该过程可能会意外退出。若要接收有关渲染过程意外终止的通知,可以使用RenderListener。当您收到有关渲染过程终止的通知时,您可以显示“悲伤”图标,例如Google Chrome,例如,以通知用户该特定的浏览器组件已崩溃。)
browser.addRenderListener(new RenderAdapter() { @Override public void onRenderCreated(RenderEvent event) { System.out.println("Render process is created."); } @Override public void onRenderGone(RenderEvent event) { System.out.println("Render process is gone:"); TerminationStatus terminationStatus = event.getTerminationStatus(); System.out.println("Termination Status: " + terminationStatus); } });
If you refresh or load the same or another URL, the render process and Browser instance will be restored. Example: (如果刷新或加载相同或另一个URL,则将还原呈现过程和浏览器实例。例:)
browser.addRenderListener(new RenderAdapter() { @Override public void onRenderGone(RenderEvent event) { Browser browser = event.getBrowser(); // Restore Browser instance by loading the same URL browser.loadURL(browser.getURL()); } });