java - JxBrowser view is gone when stage is hidden -
i have used jxbrowser in javafx app :
public class main extends application { private stage primarystage; private browser browser; private boolean firstminimize; private trayicon trayicon; public static void main(string[] args) { launch(args); } @override public void start(stage primarystage) { this.primarystage = primarystage; firstminimize = true; platform.setimplicitexit(false); createtrayicon(); browser = new browser(); browserview browserview = new browserview(browser); stackpane pane = new stackpane(); pane.getchildren().add(browserview); scene scene = new scene(pane, 380, 500); primarystage.initstyle(stagestyle.undecorated); primarystage.setscene(scene); primarystage.show(); browser.addrenderlistener(new renderadapter() { @override public void onrendergone(renderevent event) { system.out.println("here called..."); browser browser = event.getbrowser(); // restore browser instance loading same url browser.loadurl(browser.geturl()); } }); initialize(); // if not logged in showlogin(); } public void initialize() { initclosebutton(primarystage); initminimizebutton(primarystage); } public void initclosebutton(stage primarystage) { browser.registerfunction("close", new browserfunction() { @override public jsvalue invoke(jsvalue... args) { platform.runlater(new runnable() { @override public void run() { closetotray(primarystage); } }); return null; } }); } public void initminimizebutton(stage primarystage) { browser.registerfunction("minimize", new browserfunction() { @override public jsvalue invoke(jsvalue... args) { platform.runlater(new runnable() { @override public void run() { primarystage.seticonified(true); } }); return null; } }); } public void createtrayicon() { if (systemtray.issupported()) { systemtray tray = systemtray.getsystemtray(); java.awt.image image = null; try { url url = new url("http://www.digitalphotoartistry.com/rose1.jpg"); image = imageio.read(url); } catch (ioexception ex) { system.out.println(ex); } final actionlistener closelistener = new actionlistener() { @override public void actionperformed(java.awt.event.actionevent e) { system.exit(0); } }; final actionlistener showlistener = new actionlistener() { @override public void actionperformed(java.awt.event.actionevent e) { platform.runlater(new runnable() { @override public void run() { // primarystage.setopacity(0); primarystage.show(); } }); } }; popupmenu popup = new popupmenu(); menuitem showitem = new menuitem("show"); showitem.addactionlistener(showlistener); popup.add(showitem); menuitem closeitem = new menuitem("close"); closeitem.addactionlistener(closelistener); popup.add(closeitem); trayicon = new trayicon(image, "rezrem", popup); trayicon.addactionlistener(showlistener); try { tray.add(trayicon); } catch (awtexception e) { system.err.println(e); } } } public void showminimizemessage() { if (firstminimize) { trayicon.displaymessage("some message", "some other message.", trayicon.messagetype.info); firstminimize = false; } } private void closetotray(stage primarystage) { platform.runlater(new runnable() { @override public void run() { if (systemtray.issupported()) { // primarystage.setopacity(0); primarystage.hide(); showminimizemessage(); } else { system.exit(0); } } }); } public void showlogin() { browser.loadurl(main.class.getresource("templates/login.html").toexternalform()); browser.registerfunction("login", new browserfunction() { @override public jsvalue invoke(jsvalue... args) { (jsvalue arg : args) { system.out.println("arg = " + arg.getstring()); } return jsvalue.create("hello!"); } }); } }
i have set close button hide stage when clicked in function "closetotray".(in order minimize system tray) calling stage.show() brings browser browser view overall white, in other words, rendered page gone way. here screenshot of before , after minimizing system tray : before clicking close btn, after clicking show system tray
any idea?
thanks in advance
this known issue in jxbrowser 6.0.2. fix available in next update released in week.
Comments
Post a Comment