Hello,

I am new to gwt. I found out that gwt is abstracted like a desktop gui
framework where we replace panels in frames to switch screens. From
showcase example, though it was quite complex, I was able to
understand that we might use Composite derived classes as screens and
use a SimplePanel as container. And that we have to call initWidget as
last statement in constructor of Composite derived classes. So, did
something like this but it doesnt work. I am pasting my code here.
What am I missing? Thanks.

///////////////////// Application Class //////////////////////
public class Application implements EntryPoint {

    private VerticalPanel mainPanel;
    private Grid logo_and_linksBar_grd;
    private SimplePanel widgetContainer_sp;
    private HorizontalPanel miscLinks_hp;
    private Hyperlink about_hl;
    private DialogBox aboutDialogBox;
    private static Application applicationInstance;

    public static Application getAplplicationInstance(){
    return applicationInstance;
    }
    public void onModuleLoad() {

        applicationInstance=this;
        mainPanel = new VerticalPanel();
        mainPanel.setWidth("100%");

        logo_and_linksBar_grd = new Grid(1, 2);
        logo_and_linksBar_grd.setWidth("100%");

        widgetContainer_sp = new SimplePanel();
        widgetContainer_sp.setWidth("100%");

        miscLinks_hp = new HorizontalPanel();
        miscLinks_hp.setHorizontalAlignment
(HasHorizontalAlignment.ALIGN_RIGHT);
        miscLinks_hp.setSpacing(5);

        about_hl = new Hyperlink("About", "About");
        about_hl.addClickListener(new ClickListener() {

            public void onClick(Widget sender) {
                aboutClick();
            }
        });

        miscLinks_hp.add(about_hl);

        logo_and_linksBar_grd.setText(0, 0, "logo here");
        logo_and_linksBar_grd.setWidget(0, 1, miscLinks_hp);
        logo_and_linksBar_grd.getCellFormatter().
            setHorizontalAlignment(0, 1,
HasHorizontalAlignment.ALIGN_RIGHT);

        mainPanel.add(logo_and_linksBar_grd);
        mainPanel.add(widgetContainer_sp);

        RootPanel.get().add(mainPanel);

        setContent(LoginApplicationContent.getInstance());
    }

    private void aboutClick() {
        if (aboutDialogBox == null) {
            aboutDialogBox = new DialogBox(true, true);
            aboutDialogBox.setText("About");
            aboutDialogBox.add(new Label("Some thing"));
        }
        aboutDialogBox.center();
    }

    public void setContent(ApplicationContent content) {
        if (widgetContainer_sp.getWidget() != null) {
            widgetContainer_sp.remove(widgetContainer_sp.getWidget());
        }
        widgetContainer_sp.setWidget(content);
    }
}

///////////////////// ApplicationContent Class //////////////////////
abstract class ApplicationContent extends Composite {
}

///////////////////// LoginApplicationContent
Class //////////////////////
public class LoginApplicationContent extends ApplicationContent {
private static LoginApplicationContent loginpage;
    public static LoginApplicationContent getInstance() {
        if(loginpage==null)
        {
            loginpage=new LoginApplicationContent();
        }
        return loginpage;
    }

    private VerticalPanel mainPanel_vp;
    private HorizontalPanel loginControls_hp;
    private VerticalPanel login_vp;
    private Label error_lb;
    private Grid userNamePassword_grd;
    private TextBox userName_tb;
    private PasswordTextBox password_tb;
    private CheckBox remember_cb;
    private Button signIn_btn;
    private VerticalPanel introSignUp_vp;
    private Button signUp_btn;

    private LoginApplicationContent() {

        mainPanel_vp = new VerticalPanel();
        loginControls_hp = new HorizontalPanel();
        login_vp = new VerticalPanel();
        error_lb = new Label();
        userNamePassword_grd = new Grid(2, 2);
        userName_tb = new TextBox();
        password_tb = new PasswordTextBox();
        remember_cb = new CheckBox("Remember Me");
        signIn_btn = new Button("Sign In");

        signUp_btn = new Button("Sign Up");
        introSignUp_vp = new VerticalPanel();


        userNamePassword_grd.setCellSpacing(3);
        userNamePassword_grd.setText(0, 0, "User Name:");
        userNamePassword_grd.setWidget(0, 1, userName_tb);
        userNamePassword_grd.setText(1, 0, "Password:");
        userNamePassword_grd.setWidget(1, 1, password_tb);

        login_vp.setHorizontalAlignment
(HasHorizontalAlignment.ALIGN_CENTER);
        login_vp.setVerticalAlignment
(HasVerticalAlignment.ALIGN_MIDDLE);
        login_vp.add(error_lb);
        login_vp.add(userNamePassword_grd);
        login_vp.add(remember_cb);
        login_vp.add(signIn_btn);

        introSignUp_vp.setHorizontalAlignment
(HasHorizontalAlignment.ALIGN_CENTER);
        introSignUp_vp.setVerticalAlignment
(HasVerticalAlignment.ALIGN_MIDDLE);
        introSignUp_vp.add(new Label("Note:"));
        introSignUp_vp.add(signUp_btn);

        loginControls_hp.setHorizontalAlignment
(HasHorizontalAlignment.ALIGN_CENTER);
        loginControls_hp.add(login_vp);
        loginControls_hp.add(introSignUp_vp);
        loginControls_hp.setCellWidth(login_vp, "50%");
        loginControls_hp.setCellWidth(introSignUp_vp, "50%");
        loginControls_hp.setWidth("100%");

        mainPanel_vp.setHorizontalAlignment
(HasHorizontalAlignment.ALIGN_CENTER);
        mainPanel_vp.setVerticalAlignment
(HasVerticalAlignment.ALIGN_MIDDLE);
        mainPanel_vp.add(loginControls_hp);
        mainPanel_vp.setWidth("100%");
        initWidget(mainPanel_vp);
        userName_tb.setFocus(true);
    }

    private void signIn_Clicked() {
        String varify_UserName = userName_tb.getText().trim();
        if (varify_UserName.matches("^[0-9a-zA-Z]{1,15}$")) {
            password_tb.setText(userName_tb.getText());
            return;
        }
        Window.alert("'" + varify_UserName + "' is not valid");
        userName_tb.selectAll();

    }

    private void signUp_Clicked() {
        Application.getAplplicationInstance().setContent
(SignUpApplicationContent.getInstance());
    }
}

///////////////////// SignUpApplicationContent
Class //////////////////////
public class SignUpApplicationContent extends ApplicationContent{

    private VerticalPanel mainPanel_vp;
    private Grid userInput_grd;

    private TextBox userName_tb;
    private PasswordTextBox password_tb;
    private PasswordTextBox confirmPassword_tb;
    private TextBox displayName_tb;
    private TextBox email_tb;
    private TextBox confirmEmail_tb;
    private TextBox firstName_tb;
    private TextBox lastName_tb;
    private ListBox country_listbox;
    private TextBox dob_tb;
    private TextBox qualification_tb;

    private Label userName_lb;
    private Label password_lb;
    private Label confirmPassword_lb;
    private Label displayName_lb;
    private Label email_lb;
    private Label confirmEmail_lb;
    private Label firstName_lb;
    private Label lastName_lb;
    private Label country_lb;
    private Label dob_lb;
    private Label qualification_lb;

    private RadioButton male_rb;
    private RadioButton female_rb;
    private Button ok_btn;
    private Button cancel_btn;
    private HorizontalPanel button_hp;

    private CheckBox iAccept_cb;
    private static SignUpApplicationContent signUpPage;

    public static SignUpApplicationContent getInstance(){
       if(signUpPage==null)
       {
           signUpPage=new SignUpApplicationContent();
       }
       return signUpPage;
}

    private SignUpApplicationContent() {
        userInput_grd=new Grid(12, 3);
        userInput_grd.setBorderWidth(1);
        mainPanel_vp=new VerticalPanel();
        mainPanel_vp.setBorderWidth(1);

        userName_tb=new TextBox();

        password_tb=new PasswordTextBox();
        confirmPassword_tb=new PasswordTextBox();
        displayName_tb=new TextBox();
        email_tb=new TextBox();
        confirmEmail_tb=new TextBox();
        firstName_tb=new TextBox();
        lastName_tb=new TextBox();
        country_listbox=new ListBox(false);
        dob_tb=new TextBox();
        qualification_tb=new TextBox();

        userName_lb=new Label();
        password_lb=new Label();
        displayName_lb=new Label();
        email_lb=new Label();
        firstName_lb=new Label();
        lastName_lb=new Label();
        country_lb=new Label();
        country_listbox.setWidth("11em");
        dob_lb=new Label();
        qualification_lb=new Label();

        male_rb=new RadioButton("gender", "Male");
        female_rb=new RadioButton("gender", "Female");

        male_rb.setChecked(true);
        ok_btn=new Button("OK");
        ok_btn.setWidth("50");
        cancel_btn=new Button("Cancel");
        cancel_btn.setWidth("50");
        button_hp=new HorizontalPanel();

        iAccept_cb=new CheckBox("I Accept all terms and conditions");

        button_hp.setBorderWidth(1);
        button_hp.setSpacing(10);
        button_hp.add(ok_btn);
        button_hp.add(cancel_btn);
        button_hp.setHorizontalAlignment
(HasHorizontalAlignment.ALIGN_CENTER);
        button_hp.setBorderWidth(1);

        userInput_grd.setCellSpacing(10);
        userInput_grd.setText(0, 0, "User Name");
        userInput_grd.setWidget(0, 1, userName_tb);
        //userInput_grd.setWidget(0, 2, userName_lb);

        userInput_grd.setText(1, 0, "Password");
        userInput_grd.setWidget(1, 1, password_tb);
        //userInput_grd.setWidget(1, 2, password_lb);

        userInput_grd.setText(2, 0, "Confirm Password");
        userInput_grd.setWidget(2, 1, confirmPassword_tb);
        //userInput_grd.setWidget(2, 2, confirmPassword_lb);

        userInput_grd.setText(3, 0, "Display Name");
        userInput_grd.setWidget(3, 1,displayName_tb );
        //userInput_grd.setWidget(3, 2, displayName_lb);

        userInput_grd.setText(4, 0, "Email");
        userInput_grd.setWidget(4, 1, email_tb);
        //userInput_grd.setWidget(4, 2, email_lb);

        userInput_grd.setText(5, 0, "Confirm Email");
        userInput_grd.setWidget(5, 1, confirmEmail_tb);
        //userInput_grd.setWidget(5, 2, confirmEmail_lb);

        userInput_grd.setText(6, 0, "First Name");
        userInput_grd.setWidget(6, 1, firstName_tb);
        //userInput_grd.setWidget(6, 2, firstName_lb);

        userInput_grd.setText(7, 0, "Last Name");
        userInput_grd.setWidget(7, 1, lastName_tb);
        //userInput_grd.setWidget(7, 2, lastName_lb);

        userInput_grd.setText(8, 0, "Gender");
        HorizontalPanel gender_hp = new HorizontalPanel();
        gender_hp.add(male_rb);
        gender_hp.add(female_rb);
        userInput_grd.setWidget(8, 1, gender_hp);


        userInput_grd.setText(9, 0, "Select Country");
        userInput_grd.setWidget(9, 1, country_listbox);
        //userInput_grd.setWidget(9, 2, country_lb);

        userInput_grd.setText(10, 0, "Date of Birth");
        userInput_grd.setWidget(10, 1, dob_tb);
        //userInput_grd.setWidget(10, 2, dob_lb);

        userInput_grd.setText(11, 0, "Qualification");
        userInput_grd.setWidget(11, 1, qualification_tb);
        //userInput_grd.setWidget(11, 2, qualification_lb);

        mainPanel_vp.setHorizontalAlignment
(HasHorizontalAlignment.ALIGN_CENTER);
        mainPanel_vp.setVerticalAlignment
(HasVerticalAlignment.ALIGN_MIDDLE);
        mainPanel_vp.setWidth("100%");
        mainPanel_vp.add(userInput_grd);
        mainPanel_vp.add(iAccept_cb);
        mainPanel_vp.add(button_hp);
        initWidget(mainPanel_vp);
        userName_tb.setFocus(true);
    }
}

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

Reply via email to