Programação do GWT é semelhante ao do Swing?

6 respostas
L

Fazer GUI com GWT é semelhante ao quando se faz com AWT/Swing ?

Ou pelo menos quem tiver um bom conhecimento em AWT/Swing terá bastante facilidade com GWT?

6 Respostas

s4nchez

Sim, é bem parecido.

ciczan

É parecido no sentido que você pode dispor componentes em paineis, usando layouts. E adicionar listeners (chamados handlers) neles, para tratar os eventos. O RPC também é uma espécie de RMI.

Fora isso vão ter casos onde você não vai escapar de pelo menos entender um pouco de DOM, e usar o Firebug pra entender o que está acontecendo…

Eu acho que na verdade a maior vantagem do GWT é programar em Java e gerar JavaScript otimizado.

L

E quanto ao Iceface, qual diferença com GWT?

juniorsatanas

Muita coisa !mano
http://www.icefaces.org/

juniorsatanas
Using an Effect with a panelGroup

In this advanced example, we will show how to use an Effect component with a panelGroup. Here we will be adding a blindDown effect to a panel in order to reveal it.

First, setup your panelGroup, then set the effect attribute of the panelGroup to the backingBean value, and set visible to false.

	<ice:panelGroup styleClass="blindDownPanel" effect="#{customEffects.panelEffect}" visible="false">
Set the action attribute of your commandButton to the backing bean value.

<ice:panelGrid columns="2">
     <ice:panelGroup>
         <ice:outputText value="Click to reveal ICEfaces info" />
         <ice:commandButton value="Reveal" action="#{customEffects.fireEffect}"/>
     </ice:panelGroup>
     <ice:panelGroup styleClass="blindDownPanel" effect="#{customEffects.panelEffect}" visible="false">
         &lt;ice:outputText value="ICEfaces"/&gt;<br/><br/>
         &lt;ice:outputText value="ICEfaces is more than a rich component library..."/&gt;
     &lt;/ice:panelGroup&gt;
&lt;/ice:panelGrid&gt;
Then set up your backing bean as follows.

public class CustomEffects {

    private Effect panelEffect;

    /** Creates a new instance of CustomEffects */
    public CustomEffects() {
    }

    public Effect getPanelEffect() {
        return panelEffect;
    }

    public void setPanelEffect(Effect panelEffect) {
        this.panelEffect = panelEffect;
    }
    public String fireEffect(){
        panelEffect = new BlindDown();
        return null;
    }

}

gwt

/**
   * The constants used in this Content Widget.
   */
  public static interface CwConstants extends Constants,
      ContentWidget.CwConstants {
    String cwBasicPopupClickOutsideInstructions();

    String cwBasicPopupDescription();

    String cwBasicPopupInstructions();

    String cwBasicPopupName();

    String cwBasicPopupShowButton();
  }

  /**
   * An instance of the constants.
   */
  private CwConstants constants;

  /**
   * Initialize this example.
   */
  @Override
  public Widget onInitialize() {
    // Create a basic popup widget
    final DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true);
    simplePopup.ensureDebugId("cwBasicPopup-simplePopup");
    simplePopup.setWidth("150px");
    simplePopup.setWidget(new HTML(
        constants.cwBasicPopupClickOutsideInstructions()));

    // Create a button to show the popup
    Button openButton = new Button(constants.cwBasicPopupShowButton(),
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            // Reposition the popup relative to the button
            Widget source = (Widget) event.getSource();
            int left = source.getAbsoluteLeft() + 10;
            int top = source.getAbsoluteTop() + 10;
            simplePopup.setPopupPosition(left, top);

            // Show the popup
            simplePopup.show();
          }
        });

    // Create a popup to show the full size image
    Image jimmyFull = new Image(Showcase.images.jimmy());
    final PopupPanel imagePopup = new PopupPanel(true);
    imagePopup.setAnimationEnabled(true);
    imagePopup.ensureDebugId("cwBasicPopup-imagePopup");
    imagePopup.setWidget(jimmyFull);
    jimmyFull.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        imagePopup.hide();
      }
    });

    // Add an image thumbnail
    Image jimmyThumb = new Image(Showcase.images.jimmyThumb());
    jimmyThumb.ensureDebugId("cwBasicPopup-thumb");
    jimmyThumb.addStyleName("cw-BasicPopup-thumb");
    jimmyThumb.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        imagePopup.center();
      }
    });

    // Add the widgets to a panel
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.setSpacing(5);
    vPanel.add(openButton);
    vPanel.add(new HTML("<br><br><br>" + constants.cwBasicPopupInstructions()));
    vPanel.add(jimmyThumb);

    // Return the panel
    return vPanel;
  }
.gwt-PopupPanel {
  border: 3px solid #C3D9FF;
  padding: 3px;
  background: white;
}
.gwt-PopupPanelGlass {
  background-color: #000;
  opacity: 0.3;
  filter: alpha(opacity=30);
}
html&gt;body .gwt-PopupPanel {
}
* html .gwt-PopupPanel {
}
.gwt-DecoratedPopupPanel .popupContent {
}
.gwt-DecoratedPopupPanel .popupMiddleCenter {
  padding: 3px;
  background: #d0e4f6;
}
.gwt-DecoratedPopupPanel .popupTopCenter {
  background: url(images/hborder.png) repeat-x;
}
.gwt-DecoratedPopupPanel .popupBottomCenter {
  background: url(images/hborder.png) repeat-x 0px -4px;
  -background: url(images/hborder_ie6.png) repeat-x 0px -4px;
}
.gwt-DecoratedPopupPanel .popupMiddleLeft {
  background: url(images/vborder.png) repeat-y;
}
.gwt-DecoratedPopupPanel .popupMiddleRight {
  background: url(images/vborder.png) repeat-y -4px 0px;
  -background: url(images/vborder_ie6.png) repeat-y -4px 0px;
}
.gwt-DecoratedPopupPanel .popupTopLeftInner {
  width: 5px;
  height: 5px;
  zoom: 1;
}
.gwt-DecoratedPopupPanel .popupTopRightInner {
  width: 8px;
  height: 5px;
  zoom: 1;
}
.gwt-DecoratedPopupPanel .popupBottomLeftInner {
  width: 5px;
  height: 8px;
  zoom: 1;
}
.gwt-DecoratedPopupPanel .popupBottomRightInner {
  width: 8px;
  height: 8px;
  zoom: 1;
}
.gwt-DecoratedPopupPanel .popupTopLeft {
  background: url(images/corner.png) no-repeat 0px -10px;
  -background: url(images/corner_ie6.png) no-repeat 0px -10px;
}
.gwt-DecoratedPopupPanel .popupTopRight {
  background: url(images/corner.png) no-repeat -5px -10px;
  -background: url(images/corner_ie6.png) no-repeat -5px -10px;
}
.gwt-DecoratedPopupPanel .popupBottomLeft {
  background: url(images/corner.png) no-repeat 0px -15px;
  -background: url(images/corner_ie6.png) no-repeat 0px -15px;
}
.gwt-DecoratedPopupPanel .popupBottomRight {
  background: url(images/corner.png) no-repeat -5px -15px;
  -background: url(images/corner_ie6.png) no-repeat -5px -15px;
}
html&gt;body .gwt-DecoratedPopupPanel {
}
* html .gwt-DecoratedPopupPanel .popupTopLeftInner {
  width: 5px;
  height: 5px;
  overflow: hidden;
}
* html .gwt-DecoratedPopupPanel .popupTopRightInner {
  width: 8px;
  height: 5px;
  overflow: hidden;
}
* html .gwt-DecoratedPopupPanel .popupBottomLeftInner {
  width: 5px;
  height: 8px;
  overflow: hidden;
}
* html .gwt-DecoratedPopupPanel .popupBottomRightInner {
  width: 8px;
  height: 8px;
  overflow: hidden;
}
L

Por que nao criar um GUI em Swing e rodar no Applet? Qual a vantagem do GWT em relação a isso?

Criado 1 de dezembro de 2009
Ultima resposta 3 de jan. de 2010
Respostas 6
Participantes 4