Skip to content
Browse files

Moved the user-interface layout out of HTML into Java.

  • Loading branch information...
1 parent a6e6513 commit 675d720416c176816fdf7677282e09e4fcd61ca8 @Max-Hailperin committed with Mar 15, 2012
View
21 SampleWebApplication/src/edu/gac/mcs270/ui/client/SampleWebApplication.java
@@ -12,6 +12,7 @@
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
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.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
@@ -39,19 +40,31 @@
* This is the entry point method.
*/
public void onModuleLoad() {
+ final Label instructionsLabel = new Label("Please enter your name:");
final Button sendButton = new Button("Send");
final TextBox nameField = new TextBox();
nameField.setText("GWT User");
final Label errorLabel = new Label();
// We can add style names to widgets
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
- RootPanel.get("nameFieldContainer").add(nameField);
- RootPanel.get("sendButtonContainer").add(sendButton);
- RootPanel.get("errorLabelContainer").add(errorLabel);
+ RootPanel.get("applicationContainer").add(mainPanel);
// Focus the cursor on the name field when the app loads
nameField.setFocus(true);
View
13 SampleWebApplication/war/SampleWebApplication.html
@@ -46,17 +46,6 @@
<h1>Web Application Starter Project</h1>
- <table align="center">
- <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>
+ <div id="applicationContainer" align="center"></div>
</body>
</html>

0 comments on commit 675d720

Please sign in to comment.
Something went wrong with that request. Please try again.