Java.net article: Bringing Swing to the Web

Home

News: Java.net article: Bringing Swing to the Web

  1. In "Bringing Swing to the Web," author Jacobus Steenkamp discusses how one can take Swing components and render them almost purely from a Servlet, such that a developer can use Swing, quite literally, to create a web user interface. While this is far from perfect in implementation, it brings up some interesting concepts - some already brought up by other frameworks.

    For example, he points out that JSF's PhaseListener can be used to render the images - while focusing on simple servlets in the interest of brevity (and for a shorter learning curve.)

    The approach being used here for building a UI is similar to the approach advocated by Wicket and some other web frameworks, with the main difference being that instead of copying the model from Swing (or other GUI component models), it's using Swing itself, which might lead to a developer who's able to use Swing being able to render directly to a web interface.

    However, as the author points out, there are some difficulties - for example:
    So far, all of the images that we have drawn have been static. The next logical step is to make these images dynamically update themselves and appear to be "animated" from an end user's point of view.

    Although this is not achievable using pure HTML, it is possible to implement it using a small amount of JavaScript. The JavaScript will basically instruct the browser to continually poll the server for the latest version of the image. To ensure that the browser does not cache the image, a unique URL parameter is passed to the server on each request...
    It raises some interesting possibilities. Bringing JSF into the mix highlights a sort of "Holy Grail" of GUI development - if someone could manage to get Swing actually rendered well on the browser, without relying on an applet or another plugin, the possibilities might be endless.

    What do you think?

    Threaded Messages (38)

  2. swing + AJAX[ Go to top ]

    Interesting,
    If the power of swing can be combined with the concept of AJAX , it would be a great improment to Web 2.0.

    It is pain to use javascript to create interface. If it is possible to limit the javascript on the calls of xmlhttprequest, it would simplify the programming.
  3. Use applets with LMAppletserver[ Go to top ]

    Instead of trying to render swing as images why not stick to applets using LMAppletserver?

    Using LMAppletserver you don't have to worry about packaging applets or writing client-server communication protocols.

    Applet code is written together with your server code, and is deployed automatically on demand to the web browser. You can access your server-business logic as easy as you would do when writing a client on the server.

    Using LMAppletserver you'll get the power of Swing in your browser - and a very powerful and flexible development and debugging environment. Very rapid and flexible development of gui-intensive web-apps :)

    http://www.lightminds.com/ShowDocument.asp?id=729

    cheers,

    Peter
  4. Not new..[ Go to top ]

    check out echo
  5. Not new..[ Go to top ]

    Echo2.

    and Millstone (soon to have AJAX).

    And, while not AJAX enabled - WebOnSwing and WebCream.

    They've all been around for a few years.
  6. Not new..[ Go to top ]

    echo2 provides a very similar API to swing/awt and is fully AJAX powered from the ground up with incremental DOM/HTML page updates. Very cool and open source.

    -Sam
  7. IMHO Echo2 is interesting but[ Go to top ]

    check out jWings that provides an API that exactly mimics the Swing API (which Echo2 doesnt). It works and includes very many interesting tidbits and is exceptionally easy to style both with and without html-templates and css-files.
    I have also developed quite alot with Wicket as well as several applications with jWings and I must say that to use Wicket you must completely re-engineer your brain to get into it and for me, I have not really understood it yet but it works quite well in a cut-n-paste code factory.

    With jWings your Swing-skills can be used directly. You can even take a swing application, search and replace certain class-names (JPanel -> SPanel for instance) and you have yourself a working webapplication.

    I havent developed anything with Echo2 but since i discovered that it doesnt the use Swing-model and Ive been burnt by Wicket i find that Swing-style suits me and my need perfectly. I can easily switch between Rich Client and Thin Client programming without thought.
    /b
  8. IMHO Echo2 is interesting but[ Go to top ]

    check out jWings that provides an API that exactly mimics the Swing API (which Echo2 doesnt). It works and includes very many interesting tidbits and is exceptionally easy to style both with and without html-templates and css-files.I have also developed quite alot with Wicket as well as several applications with jWings and I must say that to use Wicket you must completely re-engineer your brain to get into it and for me, I have not really understood it yet but it works quite well in a cut-n-paste code factory.With jWings your Swing-skills can be used directly. You can even take a swing application, search and replace certain class-names (JPanel -> SPanel for instance) and you have yourself a working webapplication.I havent developed anything with Echo2 but since i discovered that it doesnt the use Swing-model and Ive been burnt by Wicket i find that Swing-style suits me and my need perfectly. I can easily switch between Rich Client and Thin Client programming without thought./b
    Echo (the original) did follow Swing very, very closely. I was able to convert an Echo project to a Swing project very quickly.

    They made some changes in Echo2. Not sure exactly why, but my guess is to more easily support AJAX. But really, there wasn't that big of change and other than some new widgets, it is very much like Swing. The concepts are definitely the same. Especially with EchoNG (previously EchoPoint).

    I can't seem to google JWings. Got a link?
  9. IMHO Echo2 is interesting but[ Go to top ]

    http://www.j-wings.org/

    Maybe i should check into Echo2 too but I like J-wings so much I can't just ditch her just yet.
    Excellent german quality.
  10. Perhaps a better way?[ Go to top ]

    This is something I've been working on for quite a while actually and I'm very near a preliminary release. There are some major difference in what I'm developing from the norm out there. My API is an entirely abstract UI (not Swing, but similar in many ways) so it's not specifically targetted to the web, nor is it specifically targetted towards applications. The abstract UI allows multiple implementations so you can write one UI and utilize it as a web application, a Swing application, an applet, a J2ME application, an SWT application, etc. without changing a single line of your code.

    The web site will be at http://www.jseamless.org when it released (hopefully this week), but temporarily you can see a sample of a functional application here:

    http://www.captiveimagination.com/wiki/index.php/Number_Guess

    Constructive criticism is welcome and I am interested in anyone else interested in assisting the development of this API.

    - Matthew D. Hicks
  11. Perhaps a better way?[ Go to top ]

    This is something I've been working on for quite a while actually and I'm very near a preliminary release. There are some major difference in what I'm developing from the norm out there. My API is an entirely abstract UI (not Swing, but similar in many ways) so it's not specifically targetted to the web, nor is it specifically targetted towards applications.

    funny, iv been doing the same for myself and it works better for me than any other solution out there. As soon as one ditches the markup and goes "api" a world of possibilties sees light. I think swing API is just to rich and complicated and is therefore not an abstract GUI canidate. What kind of API style do you have. I basically implemented HTML and build more richer components on top of that. Works well for me.
  12. Perhaps a better way?[ Go to top ]

    Dennis, I'd love to discuss this further if you want to e-mail me or message me over Jabber. My e-mail address is darkfrog at pyramex dot com

    The API I've been developing is focused primarily at offering elements that are shared between the web and applications (or at least can be created in both). I various components currently such as: Image (you reference the URL of an image resource), AWTImage (a drawable canvas that can be spit out on the screen as an image and updated), complete event management very similar to Swing's, the HTML implementation is completely AJAX driven, a TableLayout and BasicLayout providing the essential functionality of layout in HTML (far better than Swing's layout management system), and much more.

    -Matthew D. Hicks
  13. Echo2 is VERY interesting[ Go to top ]

    I'm using Echo2 but wrapped by the Roma Framework that generate forms starting by enhanced model.

    It allows to create mixed Echo2/HTML pages if you want.

    Echo2 is fast and well designed and is entirely based on Ajax. The documentation is not so large, but the forum is a good source for howtos and problem resolving.

    bye,
    Luca Garulli
    Blogging on: http://zion-city.blogspot.com
    http://RomaFramework.xwiki.com - The new way to build applications
    http://www.Pro-Netics.com (member of Orixo.com - The XML business alliance)
    http://www.OrienTechnologies.com - Light ODBMS, All in one JDO solution
  14. Echo2 is VERY interesting[ Go to top ]

    I agree Echo2 is an interesting API and provides a lot of features. However, the problem is that your UI is completely dependent on the web. I believe the goal of the UI frameworks of the future should be to abstract as much away as possible so you can utilize your application as a web site and then can decide to release it as a stand-alone application without having to completely rework your UI or vice-versa.

    Echo2 does show more promise as a web-based API than anything I've yet seen, it just seems the limitations come from having to convert explicitly to the web.

    -Matthew D. Hicks
  15. Echo2 is VERY interesting[ Go to top ]

    I agree with you. There should be a framework that abstracts the underline presentation framework used.

    The same thing is the persistence: there should be something abstracts the framework used (JDO, Hibernate, etc.)

    This should be the "Roma Meta-Framework" I working. I'm waiting adding some more features before to present officially the project on TSS ;-)

    bye,
    Luca Garulli
    Blogging on: http://zion-city.blogspot.com
    http://RomaFramework.xwiki.com - The new way to build applications
    http://www.Pro-Netics.com (member of Orixo.com - The XML business alliance)
    http://www.OrienTechnologies.com - Light ODBMS, All in one JDO solution
    I agree Echo2 is an interesting API and provides a lot of features. However, the problem is that your UI is completely dependent on the web. I believe the goal of the UI frameworks of the future should be to abstract as much away as possible so you can utilize your application as a web site and then can decide to release it as a stand-alone application without having to completely rework your UI or vice-versa.Echo2 does show more promise as a web-based API than anything I've yet seen, it just seems the limitations come from having to convert explicitly to the web.-Matthew D. Hicks
  16. Re: Echo2 is VERY interesting[ Go to top ]

    Can I get some simple examples of using Roma Fwk with Echo2.
  17. Re: Echo2 is VERY interesting[ Go to top ]

    Can I get some simple examples of using Roma Fwk with Echo2.
  18. Echo2 is VERY interesting[ Go to top ]

    I agree Echo2 is an interesting API and provides a lot of features. However, the problem is that your UI is completely dependent on the web.

    Having "converted" an Echo project to a Swing project, I can say this isn't really true.
    Echo2 does show more promise as a web-based API than anything I've yet seen, it just seems the limitations come from having to convert explicitly to the web.
    Any limitations are because of the limitations of html.
  19. Echo2 is VERY interesting[ Go to top ]

    Having "converted" an Echo project to a Swing project, I can say this isn't really true.

    However, the "conversion" is still necessary. No matter how close they are there will always be a conversion necessary unless you have an abstract UI. The idea with jSeamless is that you can deploy it on the web and as an application in Swing simultaneously if you like and there isn't any UI synchronization that has to occur and hook up with the data model. Echo2 is a pretty nice system, and I'm sure the conversion process is not nearly as heavy as trying to convert from HTML to Swing, but until the conversion is no longer necessary you have to ask yourself why?

    Specifically because Echo and Swing are so similar why not go one more step and make them one and the same? Then you have the best of both worlds and you can really have a "design first" approach because then you don't have to get an early decision on where this application will be deployed because it just doesn't matter anymore to the UI.

    I've put up my preliminary work: http://www.jseamless.org but it is very early alpha. I will be completely re-writing many of the aspects of the API before the next alpha release. Comments and constructive criticism are much appreciated.

    -Matthew D. Hicks
  20. Echo2 is VERY interesting[ Go to top ]

    I think we are saying, or rather, thinking the same thing.

    At the time, the conversion mostly consisted of changing package names and reversing some parameters in the table model.

    With Echo2, it would take more work.

    I'll give jseamless a look. I had wanted to do the same sort of thing.
  21. Echo2 is VERY interesting[ Go to top ]

    Great, I look forward to some good feedback. It's still at an early stage of development, but that also means there's lots of room for change right now if you or anyone else that sees that has any ideas or is willing to help in the development the idea is to build the future of UI development.

    -Matthew D. Hicks
  22. Re: Echo2 is VERY interesting[ Go to top ]

    Currently I am doing some work on Echo2 framework and loooks pretty good to me as I can now avoid using those javascripts mix ups with JSP. Anyways when we talk about JSeamLess I can think of some usage of a databinding to the UI components.I hope you are taking care of this. Rgds Shashank
  23. http://www.canoo.com/ulc/
  24. Checkout ZK[ Go to top ]

    ZK is just as capable and more.
  25. http://www.creamtec.com/webcream/

    take a swing app and deploy it to a browser (no plugin). The Swing components are rendered into HTML markup.

    Not perfect but pretty darn good.
  26. http://www.creamtec.com/webcream/take a swing app and deploy it to a browser (no plugin). The Swing components are rendered into HTML markup.Not perfect but pretty darn good.

    Sounds good. The factor: costs of a third-part solution on the presentation-level(only...), is in commercial applications a important criterion, too.

    Especially when are installations on various hosts indispensable.

    -roland
  27. Mostly for the web...
    Swing has rather failed in the RDA (Rich Desktop Application) kink of application. RCPs try to enhance the model.
    Web can be considered has more productive but resulting code lake of main maintainability, testability ..
    RIA (Rich Internet Application) solutions will find a good trade-off between all these quality attributes. I'm not sure that Swing is the silver bullet :)

    MAC
  28. Swing is good for RIA..[ Go to top ]

    I do believe that Swing is the best solution for intranet applications. Java WebStart and Pack200 is really good for deploying applications. Pack200 is very good at compressing jar files.HTML based applications should be preferred only, if your application is available to public.

    Swing has won unfairly bad reputation because of Java Applet failure. For example, one of the big bank in my country, they had implemented their banking applications with applet in 1999, it was a big failure. Because the applet size is about 2 mb and all the client's internet connections are about 33kbit.. They lost money and credibility. And they re-implemented it with servlet.
  29. Swing is good for RIA..[ Go to top ]

    If you are looking for a webstart type solution, check out jThinRich. It fills in the missing gaps of webstart. It provides a browser type metaphore for developers and provides a POJO http api to easily tie client actions to your servlet engine.

    -Sam
  30. Lifting desktop to web[ Go to top ]

    Isn't it, like, easier to use one of many VNC Java Applet clients to actually open a desktop session in the browser? And it's not like the approach that Swing takes is the best one -- it' isn't really an application building framework, it's more like a rendering framework...

    I think that approach of Wicket and Aranea (shameless commercial) is much better -- make web object-oriented, but don't try to lift the desktop to the web -- you lose more than you gain...
  31. Maybe the first problem of Swing is their name - which is longer then 3 characters :) For this reason, here is a other new challenge: RSI - Rich Swinging Internet-Application ;-)


    Now, in serious:

    In my opinion Swing, SWT,... are destinated for applications, which needs a very restrictive status-handling and has a high frequently, complex structure and numerously input by the data-entry.

    On the other side, Web-based solutions are great for solutions, which are more destinated to data-queries, with few need of data-entry and non-restrictive status-handling (Use of Browser's Back-Botton is no causing in a disaster...)

    Swing/SWT/... needs today a fixed installation on the client-side (alternately downloading an applet) - this can produce problems by the maintenance of high volumed client-installations, but can be simplier with Web-Start, mayme ...

    Web-based solutions needs only the browser. On the other side, all the handling/processing is destinated exclusively to the server-side, which can produce high traffic on potential slow communication channels and needs powerfull servers. Using JavaScript, perhaps can try trouble with the Browser-Compatibility. Maybe AJAX can resolve some of this problems in the near future.

    BTW: I have seen good developments in commercial projects, which are providing great solutions for both areas - switching only the rendering-part on runtime to Swing, Web and others ... without any other specialized changes or definitions. Maybe Swing is applicable to RIA (R=Rich I=Internet A=Application) too ?

    -roland
  32. Oops. Sorry - the reply was correctly destinated to "Big whoop. Was done years ago."
  33. Maybe the first problem of Swing is their name - which is longer then 3 characters :) For this reason, here is a other new challenge: RSI - Rich Swinging Internet-Application ;-)

    RSI means 'Repetitive Strain Injury'. I suffer from it and it's not funny.
  34. Maybe the first problem of Swing is their name - which is longer then 3 characters :) For this reason, here is a other new challenge: RSI - Rich Swinging Internet-Application ;-)
    RSI means 'Repetitive Strain Injury'. I suffer from it and it's not funny.

    I think, many abbreviations addressing different significances - without any coherency. The header of my posting and this thread too, are mentioned exxesive to a specialized theme of information technologies.

    So, I very much apologize to those casual relation.

    -roland
  35. I think Swing combinded with JavaWebStart is a great solution to build rich clients. The only problem I think is that the JVM is not as ubicuous as the browsers. But perhaps that will be solved when there are many applications available that would make the users download the JVM.
  36. Swing is OK to build RIA[ Go to top ]

    I think Swing combinded with JavaWebStart is a great solution to build rich clients. The only problem I think is that the JVM is not as ubicuous as the browsers. But perhaps that will be solved when there are many applications available that would make the users download the JVM.
    There sure are alot of people playing games on Yahoo - and they use Java.
  37. Pointless[ Go to top ]

    Rendering Swing window content as an image won't help to send data from browser to the server, so the most common use case - the data entry form - is not covered by this technique. What is covered, besides useful but well-known approach to charts? Right, image buttons. Hate them. Now I can use Swing to draw them. In-#$%^$#$-valuable.
  38. Wrong approach[ Go to top ]

    I don't think that you can project the complexity of the Swing API onto the client-side by rendering its components to images:
    - What about event handling?
    - Scalability: I cannot imagine running thousands of highly active sessions on a server which are rendering Swing components to images.
    - Network bandwidth: HTML-applications tend to saturate networks. If you are transmitting your user interface as images this will get worse.

    If you really need the functionality of Swing on the client side while enjoying a server-side API something like ULC (http://www.canoo.com/ulc is far better suited.

    --Bruno
  39. Hi together,

    i found the suggestions given here very interesting.
    I am looking for an open source tool where i can build a web application with tree, table, graph view of elements, exporting files, uploading files from client etc and i am not sure which is the best tool i can use for doing that. Previously i used to do all this with swing, but now the req are to make it web based and i am very much confused. Especially since i want it to be a really cool application with nice look-and-feel...
     
    I even checked out echo and i think its a great tool. I wasnt able to test all the functionalities but i think it includes quite some nice features.

    What do you suggest for this type of appl ?