Skip to content
William Antônio Siqueira edited this page Feb 23, 2018 · 4 revisions

Here is our first example that shows how to use Lienzo in your GWT application.

In Eclipse

This assumes you have installed the Google Plugin for Eclipse

1. Create New > Project > Google > Web Application Project

  • Name: lienzo-hello-world
  • Package: my.lienzo.hello.world
  • Generate Sample Code: yes
2. Add this to Lienzo_hello_world.gwt.xml
<inherits name='com.ait.lienzo.Lienzo' />
  • Add Lienzo JAR file to the project's classpath
  • If it is a maven project add the following dependency:
<dependency>
    <groupId>com.ahome-it</groupId>
    <artifactId>lienzo-core</artifactId>
    <version>2.0.279-RELEASE</version>
</dependency>

3. Set the contents of war/Lienzo_hello_world.html to:

<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script type="text/javascript" language="javascript" src="lienzo_hello_world/lienzo_hello_world.nocache.js"></script>
  </head>
  <body>
  </body>
</html>
  
4. Change class /lienzo-hello-world/src/my/lienzo/hello/world/client/Lienzo_hello_world.java
package my.lienzo.hello.world.client;

import com.ait.lienzo.client.core.shape.Layer;
import com.ait.lienzo.client.core.shape.Text;
import com.ait.lienzo.client.core.types.ColorName;
import com.ait.lienzo.client.widget.LienzoPanel;
import com.ait.lienzo.client.core.types.Shadow;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class Lienzo_hello_world implements EntryPoint
{
    public void onModuleLoad()
    {
        LienzoPanel panel = new LienzoPanel(400, 300);
        RootPanel.get().add(panel);
        
        Text text = new Text("Hello World!", "Verdana, sans-serif", "italic bold", 40);
        text.setX(10).setY(100);
        text.setFillColor(ColorName.CORNFLOWERBLUE);
        text.setStrokeColor(ColorName.BLUE);
        text.setShadow(new Shadow(ColorName.DARKMAGENTA, 6, 4, 4));
        
        Layer layer = new Layer();
        panel.add(layer);

        layer.add(text);
        layer.draw();
    }
}
5. Start the application and go to its URL in a browser.
Clone this wiki locally