Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Moved the user-interface layout out of HTML into Java.
  • Loading branch information
Max-Hailperin committed Mar 16, 2012
1 parent a6e6513 commit 675d720
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Expand Up @@ -12,6 +12,7 @@
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox; import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.TextBox;
Expand Down Expand Up @@ -39,19 +40,31 @@ public class SampleWebApplication implements EntryPoint {
* This is the entry point method. * This is the entry point method.
*/ */
public void onModuleLoad() { public void onModuleLoad() {
final Label instructionsLabel = new Label("Please enter your name:");
final Button sendButton = new Button("Send"); final Button sendButton = new Button("Send");
final TextBox nameField = new TextBox(); final TextBox nameField = new TextBox();
nameField.setText("GWT User"); nameField.setText("GWT User");
final Label errorLabel = new Label(); final Label errorLabel = new Label();


// We can add style names to widgets // We can add style names to widgets
sendButton.addStyleName("sendButton"); sendButton.addStyleName("sendButton");
errorLabel.addStyleName("error");
instructionsLabel.addStyleName("instructions");

// Create some panels to hold the widgets together
final VerticalPanel mainPanel = new VerticalPanel();
final HorizontalPanel entryPanel = new HorizontalPanel();

// Assemble the widgets into the panels
entryPanel.add(nameField);
entryPanel.add(sendButton);
mainPanel.add(instructionsLabel);
mainPanel.add(entryPanel);
mainPanel.add(errorLabel);


// Add the nameField and sendButton to the RootPanel // Add the mainPanel to the RootPanel
// Use RootPanel.get() to get the entire body element // Use RootPanel.get() to get the entire body element
RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("applicationContainer").add(mainPanel);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("errorLabelContainer").add(errorLabel);


// Focus the cursor on the name field when the app loads // Focus the cursor on the name field when the app loads
nameField.setFocus(true); nameField.setFocus(true);
Expand Down
13 changes: 1 addition & 12 deletions SampleWebApplication/war/SampleWebApplication.html
Expand Up @@ -46,17 +46,6 @@


<h1>Web Application Starter Project</h1> <h1>Web Application Starter Project</h1>


<table align="center"> <div id="applicationContainer" align="center"></div>
<tr>
<td colspan="2" class="instructions">Please enter your name:</td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
<tr>
<td colspan="2" class="error" id="errorLabelContainer"></td>
</tr>
</table>
</body> </body>
</html> </html>

0 comments on commit 675d720

Please sign in to comment.