{"id":289,"date":"2007-05-31T09:39:55","date_gmt":"2007-05-31T14:39:55","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/index.php\/2007\/05\/31\/seamless-web-browser-integration\/"},"modified":"2007-05-31T09:39:55","modified_gmt":"2007-05-31T14:39:55","slug":"seamless-web-browser-integration","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2007\/05\/31\/seamless-web-browser-integration\/","title":{"rendered":"Seamless Web Browser Integration"},"content":{"rendered":"<p>The complete title for this JavaOne 2007 BOF was Ingredients for a Killer Application &#8211; Adding Mojo to Your Swing and Ajax Applications with Seamless Web Browser Integration.  Wow, what a mouthful.  It might not be immediately clear from the title but the focus of this BOF was the use of the <a href=\"https:\/\/jdic.dev.java.net\/\">JDesktop Integration Components<\/a> (JDIC) Web Browser embedded in a Swing application.  As we all know Swing does not a complete Java-based web browser component, although there is a good <a href=\"https:\/\/xhtmlrenderer.dev.java.net\/\">XHTML Renderer<\/a>.  With the JDIC you can embed a native browser (IE, Firefox, or Safari) in your Swing application.  Unlike the XHTML Renderer, the native browser allows you to run JavaScript code, apply AJAX\/Web.2.0 effects, manipulate the DOM, and more.<\/p>\n<p>Integrating JDIC into your project is as simple as adding the jar.  A key demonstration of this BOF was to show how to have bi-directional native browser communication with your Swing application.  To use the JDIC native browser, just create a WebBrowser object and invoke the executeScript method passing some JavaScript code in a string to communicate from the JVM to the browser.<\/p>\n<p>To work your way from the broswer to the Java process you need to listen to the statusTextChange method on the WebBrowserListener.  The statusTextChange method would be called when you set a string value to the browser window, as in the following JavaScript code.<\/p>\n<p>[source:javascript]<br \/>\nwindow.status = &#8220;message passed to the JVM&#8221;;<br \/>\nwindow.status = &#8220;&#8221;;<br \/>\n[\/source]<\/p>\n<p>The speaker did warn the audience that using the status text to listen for processing instructions from the browser was a total and complete hack.  The speaker recommended that as soon set the status to communicate with the JVM that you clear the command\/message.  The speaker talked about having your own mini-protocol to pass data and instructions to the JVM, I would recommend you use a standard like <b>JSON<\/b>.<\/p>\n<p>Someone in the audience asked about having access to the x, y location of DOM elements in the browsers to combine with Java 2D overlays and effects, but the speaker was not sure how to go about implementing such a task.<\/p>\n<p>Using the JDIC native web browser in your Swing application you can take advantage of Web 2.0 services such as Google Maps and Flickr in a <b>Swing\/Web 2.0 mashup<\/b>.  I have been looking into the JDIC web browser so that I can create a offline standalone web-based application by embedding a browser, <a href=\"http:\/\/www.juixe.com\/techknow\/index.php\/2007\/04\/25\/embedding-jetty\/\">Jetty<\/a>, <a href=\"http:\/\/www.juixe.com\/techknow\/index.php\/2007\/04\/09\/embedding-hsqldb\/\">HSQLDB<\/a>, and JRuby on Rails.  Embedding all these components is easy enough to integrate, although you might have to write some glue code to make into a fully stacked framework.<\/p>\n<p>Technorati Tags: <a href=\"http:\/\/technorati.com\/tag\/javaone\" rel=\"tag\">javaone<\/a>, <a href=\"http:\/\/technorati.com\/tag\/javaone2007\" rel=\"tag\"> javaone2007<\/a>, <a href=\"http:\/\/technorati.com\/tag\/jdic\" rel=\"tag\"> jdic<\/a>, <a href=\"http:\/\/technorati.com\/tag\/browser\" rel=\"tag\"> browser<\/a>, <a href=\"http:\/\/technorati.com\/tag\/xhtmlrenderer\" rel=\"tag\"> xhtmlrenderer<\/a>, <a href=\"http:\/\/technorati.com\/tag\/rails\" rel=\"tag\"> rails<\/a>, <a href=\"http:\/\/technorati.com\/tag\/jruby\" rel=\"tag\"> jruby<\/a>, <a href=\"http:\/\/technorati.com\/tag\/jetty\" rel=\"tag\"> jetty<\/a>, <a href=\"http:\/\/technorati.com\/tag\/hsqldb\" rel=\"tag\"> hsqldb<\/a>, <a href=\"http:\/\/technorati.com\/tag\/web.20\" rel=\"tag\"> web.20<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The complete title for this JavaOne 2007 BOF was Ingredients for a Killer Application &#8211; Adding Mojo to Your Swing and Ajax Applications with Seamless Web Browser Integration. Wow, what a mouthful. It might not be immediately clear from the title but the focus of this BOF was the use of the JDesktop Integration Components [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[8,13,15,22,3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-4F","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/289"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=289"}],"version-history":[{"count":0,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/289\/revisions"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=289"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}