I lack your experience with all those frameworks, but I think I understand 
people's general grief with Java-based UI development, whether it is deserved 
of 
not.  It seems a lot of people are unhappy with the API and the boilerplate.  
And also very commonly, they want simple declarative syntax for the UI (Java FX 
script pushed that point pretty hard, as we can all remember).

But I'm not prepared to throw the baby with the bathwater just yet.  Java still 
has some elegance left in her to fulfill much of the declarative UI syntax 
need.  With generics, optional arguments, and static imports, a lot of this 
work 
gets easier.  I'll outline some of the patterns I developed in my use of GWT, 
but they can be easily translated to other Java GUI frameworks (I'm doing this 
from memory, so I may not get some of the API names correctly, but you get the 
idea):

public class Util
{
  public static <P extends Panel> P panel(P panel, Widget... widgets) 
  {
    for(Widget w : widgets)
      p.add(w);
    return panel;
  }

  public static <W extends UIObject> W css(W widget, String... styles)
  {
    for(String style : styles)
      widget.addStyleName(style);
    return widget;
  }
}

import static Util.*;
public class MyGui implements EntryPoint
{
  public void onModuleLoad()
  {
    panel(
      css(RootPanel.get(), "main"),
      panel(
        new HorizontalPanel(),
        css(new InlineLabel("Hello, world!"), "helloLabel"),
        css(new Button("click me"), "button");
    );   
  }
}



 Alexey





________________________________
From: Reinier Zwitserloot <reini...@gmail.com>
To: The Java Posse <javaposse@googlegroups.com>
Sent: Fri, November 5, 2010 2:50:34 PM
Subject: [The Java Posse] Re: Evolution from web to desktop?

I've spent lots of time writing desktop-esque apps in AWT, Swing, SWT,
and javascript/html/css. The last one of that list of 4 was by far the
easiest to write in.

On Nov 5, 6:54 pm, Rob Ross <rob.r...@gmail.com> wrote:
> On Nov 4, 2010, at 11:21 AM, Reinier Zwitserloot wrote:
>
>
>
>
>
>
>
>
>
> > I'd love to believe it. I'd be somewhat more convinced if there were
> > libraries / frameworks out there that let you write a desktop app in
> > the form of servlets and templates / static HTML/js/css files, and
> > some hooks for app startup, shutdown, and some interaction for the
> > very minimal "chrome" (UI elements) on the window edges, and then
> > packages it up for you into a single executable which, when run, opens
> > a webkit / gecko embedded browser, starts up an internal server, and
> > makes it "just work".
>
> > Something like iTunes (the music store part runs on HTML, or so I
> > hear), or Steam (which is all HTML running on top of an embedded
> > webkit).
>
> > As far as I know no such tool is available for java, nor for python,
> > ruby, or the CLR. Personally I'd say such a desktop environment would
> > easily be far nicer to write in than swing, and has the considerable
> > advantage that you can share a lot of code between this desktop
> > version and a web-based app. You also can use all the latest and
> > greatest HTML5 features, because you know exactly what kind of browser
> > you end up running on (though this conflicts with the "hey, I can turn
> > this into a webapp in a snap" idea).
>
> I think Swing is a pretty great environment for writing desktop apps, but 
> that 
>comes with lots of practice.
>
> I find it highly amusing that people are bemoaning how hard it is to write 
>desktop apps in an HTML browser.
>
> Well DUH. It was never designed for that purpose. It is designed to display 
>marked-up text. Period. Everything else has been bolted on with staples and 
>duct 
>tape.
>
> If you want to write a desktop application, use a desktop application 
> framework 
>like Swing or SWT (in the Java world), or Qt if you want to go mostly-native 
>but 
>a little cross platform. Or if cross platform is not an issue at all, use 
>Cocoa 
>on the Mac and/or .Net on Windows.
>
> I think maybe the reason there's so much effort to turn the browser into 
>something it was never meant to be is that like all humans, people tend to 
>stick 
>with what they know, and don't want to invest the mental energy into learning 
>new frameworks (like Swing) that have already solved all these problems.
>
> Rob

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javapo...@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.


      

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javapo...@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to