News: Swing Browser - HTTP client for Swing components
https://swingbrowser.dev.java.net/ is an open source project initiated to develop a simple browser for swing components. Swing is mature UI toolkit from Sun for developing GUI.
- Posted by: Ejaz Mohammed
- Posted on: December 16 2008 07:49 EST
It is, however, limited only to java developers who know how to write java programs. Even these developers would agree that you need to write lot of code to create swing programs – plus modifications or changes on UI also require code changes.
There have some attempts made to put UI definition in XML form and then write a program which converts this definition into Swing components. This however suffers one major problem – you end up mixing UI and business logic together in same XML document. This also means that your client becomes heavy-weight.
Swing browser is a java application designed to render swing components by downloading/uploading (GET/POST) swing markup language (SML) documents from a web server.
The SML document looks like html; however instead of html tags it has tags for JPanel, JLabel, JTree, JTable and other components. It also supports layout managers available in awt/swing.
It is designed keeping page authors and developers in mind; thus the complexities of swing development are eliminated / minimized wherever possible. For example - you can populate data for table just like you do in html using tags for rows / columns. You do not have to provide listeners if you wish to process everything on server side.
In short it works just like any web browser, except that user and developers work with swing components.
- Neat idea by Dan Howard on December 16 2008 11:29 EST
- close to Sage browser by Dominique De Vito on December 16 2008 17:48 EST
- related projects by Dominique De Vito on December 16 2008 19:05 EST
- Re: Swing Browser - HTTP client for Swing components by Kit Davies on December 17 2008 04:52 EST
You might need to add scripting support I think as well for client side stuff. It would be neat as well if you could support basic CSS (only decorations). You might be able to use the built-in Rhino engine for the scripting.
Are you saying that we should CSS to control styles for swing components ? This application does'nt render html documents ...it renders SML (swing markup language) documents. Though I do like the idea of using CSS instead of swing properties ...
Yes. One of the difficulties of desktop apps in general is that they are not easy to re-style like web apps. If you could support basic CSS styling with external CSS files it would be real time saver. Especially for organization which build both types of applications and want a consistent look and feel.
Ok. In traditional destkop apps, styles are coded in UI application - it's part of the code. Here style is part of SML document ... In the example below, you cna see the alignment, colors specified as part of document .. I will still think about keeping sytle in CSS ..
(1) It looks like, in spirit, close to Sage browser from Don DeCoteau. Here is the Sage project.
Sage has a special markup language (SDF) and associated MIME type (text/x-sdf) that lets it render Swing-based applications, the same way a web browser uses HTML to render documents.Sage supports also scripting:
DSL is good for developers ...what about non developers? I know JavaFX uses DSL model ...but currently people are more used to HTML ...
DSL is good for developers ...what about non developers?Well, I am sick of XML as a language, I rather prefer a DSL. And, when I see how complicated JS programming could be, I think developers could learn DSL. This being said, you are right, people are more keen on HTML-like programming.
I know JavaFX uses DSL model ...but currently people are more used to HTML ...
DSL should be easy to write in JavaCC or ANTLR. However currently I use XML for data/schema. Schema is specified in RELAX-NG form - I just RELAX-NG validator over incoming input XML. You don't need to compile schema ...
Other than Sage project, there are other related projects. JAXX (BSD license) : JAXX is an open-source XML User Interface framework for Java. JAXX enables you to write simple XML files describing components and their interactions, and then compile those XML files into ordinary Java classes. This projects has been created by Ethan Nicholas. Ethan has also written about another project of his own : Java CSS (GPL license). How Swing Browser is related to JAXX ? Thanks.
Swing Browser does not compile xml into .java or .class. Instead, the renderer component of swing browser parses and renders the components on the fly. When you visit another url, it downloads SML document and renders it again - just like a web browser.
There have some attempts made to put UI definition in XML form and then write a program which converts this definition into Swing components. This however suffers one major problem – you end up mixing UI and business logic together in same XML document.Minor gripe: SwiXML has UI definition in XML with events bound to logic in regular java classes. Anyway, good luck! Kit