Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Alignment Problems in SmartGWT

    Hi,

    I am developing an application in Smartgwt2.2. The problem that i am facing is that the layouts, buttons and the layout contents are not getting aligned in the center.

    I have tried using setAlign(Alignment.CENTER), setLayoutAlign(Alignment.CENTER) and even tried writing a css for center alignment but none have worked.
    Please Help!!!

    Thanks

    #2
    How about posting your attempted code providing additional information?

    Comment


      #3
      I want vlayout to be in the center of the page....is it some smartgwt issue or am i going wrong somewhere? Please help me...







      public class Login extends VLayout {

      private final UserServiceAsync userService = GWT
      .create(UserService.class);

      private static final String SERVER_ERROR = "An error occurred while "
      + "attempting to contact the server. Please check your network "
      + "connection and try again.";

      private static final String DESCRIPTION = "Login";

      public Login() {
      super();

      GWT.log("init Login()...", null);
      this.setBackgroundColor("#FFFFFF");
      this.setWidth100();
      this.setLayoutAlign(Alignment.CENTER);

      DynamicForm form = new DynamicForm();
      VLayout vlayout = new VLayout();



      final TextItem UserNameItem = new TextItem();
      UserNameItem.setTitle("User Name ");

      final PasswordItem PWItem = new PasswordItem();
      PWItem.setTitle("Password ");


      Button button = new Button();
      button.setTitle("Login");
      button.setStyleName("center");
      button.setAlign(Alignment.CENTER);


      form.setFields(new FormItem[] { UserNameItem, PWItem });
      final HTML serverResponseLabel = new HTML();
      this.addMember(serverResponseLabel);

      class MyHandler implements ClickHandler, KeyUpHandler {

      public void onClick(ClickEvent event) {
      sendNameToServer();
      }

      public void onKeyUp(KeyUpEvent event) {
      if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
      sendNameToServer();
      }
      }

      private void sendNameToServer() {

      userService.login((String) UserNameItem.getValue(),
      (String) PWItem.getValue(),
      new AsyncCallback<String>() {

      public void onFailure(Throwable caught) {
      SC.say("Remote Procedure Call - Failure");

      serverResponseLabel
      .addStyleName("serverResponseLabelError");
      serverResponseLabel.setHTML(SERVER_ERROR);
      }

      public void onSuccess(String result) {
      serverResponseLabel
      .removeStyleName("serverResponseLabelError");
      if ("SuperAdmin".equals(result)) {
      new SuperAdminWelcome();
      }else if("Admin".equals(result)){
      new AdminWelcome();
      }else if("User".equals(result)){
      new UserWelcome();
      } else {
      SC.say("Username or password incorrect");
      }
      }
      });
      } // end sendnametoserver
      }
      MyHandler handler = new MyHandler();
      button.addClickHandler(handler);
      vlayout.addMember(form);
      vlayout.addMember(button);
      vlayout.setLayoutAlign(Alignment.CENTER);
      vlayout.setStyleName("center");
      this.addMember(vlayout);

      } // end login

      Comment

      Working...
      X