Link to home
Create AccountLog in
Avatar of jazzIIIlove
jazzIIIloveFlag for Sweden

asked on

GWT code fails with a blank screen for Verticalpanel instance. Why?

Hi there;

I have a sample code for GWT. It should be displaying a simple labels and htmls in a vertical panel but it doesn't. It only displays "Label Widget Demonstration" in the html file.

I couldn't figure out the problem. Any help? Following is the codes:

//LabelGWT.java
package com.jazziiilove.gwt.label.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class LabelGWT implements EntryPoint
{
	public void onModuleLoad()
	{
		// create two labels
		Label label1 = new Label("This is the first GWT label");
		Label label2 = new Label("This is second GWT Label");
		
		// use UIObject methods to set label properties
		label1.setTitle("Title of the first label");
		label1.addStyleName("gwt-Green-Border");
		label2.setTitle("Title of the second label");
		label2.addStyleName("gwt-Blue-Border");

		label2.setPixelSize(280, 25);   
		label1.setPixelSize(280, 25);
		
		// create two HTML widgets
		HTML html1 = new HTML("This is the first GWT HTML widget using <b> tag of html");
		HTML html2 = new HTML("This is the second GWT HTML widget using <i> tag of html");
		
		//use UIObject methods to set HTML widget properties
		html1.addStyleName("gwt-Green-Border");
		html2.addStyleName("gwt-Blue-Border");
		
		// add labels to the root panel
		VerticalPanel panel = new VerticalPanel();

	    //panel.setPixelSize(500, 400);

		panel.add(label1);
		panel.add(label2);
		panel.add(html1);
		panel.add(html2);
		// panel.setVisible(true);
		RootPanel.get("gwtContainer").add(panel);	
	}
}

Open in new window


LabelGWT.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='UIBinderGWT'>
	<inherits name='com.google.gwt.user.User' />
	<inherits name='com.google.gwt.uibinder.UiBinder' />

	<inherits name='com.google.gwt.user.theme.standard.Standard' />

	<!-- Specify the app entry point class -->
	<entry-point class='com.jazziiilove.gwt.label.client.LabelGWT' />

	<!-- Specify the paths for translatable code -->
	<source path='client' />
	<source path='shared' />
</module>

Open in new window


web.xml
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
	<!-- TODO: Add <servlet> tags for each servlet here. -->
	<!-- TODO: Add <servlet-mapping> tags for each <servlet> here. -->
	<!-- TODO: Optionally add a <welcome-file-list> tag to display a welcome file. -->
	<!-- Default page to serve -->
	<welcome-file-list>
		<welcome-file>LabelGWT.html</welcome-file>
	</welcome-file-list>
</web-app>

Open in new window


LabelGWT.css
body {
	text-align: center;
	font-family: verdana, sans-serif;
}

h1 {
	font-size: 2em;
	font-weight: bold;
	color: #777777;
	margin: 40px 0px 70px;
	text-align: center;
}

.gwt-Label {
	font-size: 150%;
	font-weight: bold;
	color: red;
	padding: 5px;
	margin: 5px;
}

.gwt-Green-Border {
	border: 1px solid green;
}

.gwt-Blue-Border {
	border: 1px solid blue;
}

Open in new window


<!--LabelGWT.html-->
<!DOCTYPE HTML>
<html>
<head>
<title>Label Example</title>
<link rel="stylesheet" href="LabelGWT.css" />
<script language="javascript" src="labelgwt/labelgwt.nocache.js">
</script>
</head>
<body>
<h1>Label Widget Demonstration</h1>
<div id="gwtContainer"></div>
</body>
</html>

Open in new window

Regards.
ASKER CERTIFIED SOLUTION
Avatar of jazzIIIlove
jazzIIIlove
Flag of Sweden image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of jazzIIIlove

ASKER

a copy paste and forgetting a refactoring..