<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Eduzine© - &quot;Hello, World!&quot;</title>
    <link>http://eduzine.edujini-labs.com/</link>
    <description>Articles from Edujini Team</description>
    <dc:language>en</dc:language>
    <admin:errorReportsTo rdf:resource="mailto:" />
    <generator>Serendipity 0.8.2 - http://www.s9y.org/</generator>
    <pubDate>Thu, 26 Jun 2008 20:59:33 GMT</pubDate>

    <image>
        <url>http://www.edujini-labs.com/images/newmasthead.gif</url>
        <title>RSS: Eduzine© - &quot;Hello, World!&quot; - Articles from Edujini Team</title>
        <link>http://eduzine.edujini-labs.com/</link>
        <width></width>
        <height></height>
    </image>
<item>
    <title>Standard Widget Toolkit: Part 1 - Hello, World!</title>
    <link>http://eduzine.edujini-labs.com/archives/37-Standard-Widget-Toolkit-Part-1-Hello,-World!.html</link>
<category>Eclipse</category><category>SWT</category><category>&quot;Hello, World!&quot;</category>    <comments>http://eduzine.edujini-labs.com/archives/37-Standard-Widget-Toolkit-Part-1-Hello,-World!.html#comments</comments>
    <wfw:comment>http://eduzine.edujini-labs.com/wfwcomment.php?cid=37</wfw:comment>
    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://eduzine.edujini-labs.com/rss.php?version=2.0&amp;type=comments&amp;cid=37</wfw:commentRss>
    <author>eduzine@edujinionline.com (Eduzine)</author>
    <content:encoded>

&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;
With this article, we start a series on Standard Widget Toolkit (SWT) and Eclipse Plug-in Framework at Eduzine&lt;sup&gt;©&lt;/sup&gt;. It is assumed that you have already heard about Eclipse and you are gungho about exploring it and may be getting into all its details.
&lt;/p&gt;

&lt;p&gt;
SWT is the base UI toolkit to create the UI, mainly the native widgets. Then there is JFace, an abstraction that sits on top of JFace (a large part of it) and adds power to native widgets. And finally, there is Eclipse Plug-in Framework that helps creating applications in a modular fashion. Default implementation of the Eclipse Workbench (the main UI cockpit) uses SWT and JFace for its UI.
&lt;/p&gt;

&lt;p&gt;
Following the tradition started few decades back, we start with &amp;quot;Hello, World!&amp;quot; application.
&lt;/p&gt;

&lt;h2&gt;Downloads&lt;/h2&gt;

&lt;p&gt;
The downloads are available in the &lt;a href=&quot;http://downloads.edujini-labs.com&quot;&gt;Downloads&lt;/a&gt; area in the &lt;a href=&quot;http://downloads.edujini-labs.com/index.php?act=category&amp;id=28&quot;&gt;Eclise Standard Widget Toolkit&lt;/a&gt; category.
&lt;/p&gt;

 
&lt;h2&gt;Pre-requisites&lt;/h2&gt;

&lt;p&gt;
To get started, the following pre-requisites would be considered:
&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You know Java programming langauge.&lt;/li&gt;
  &lt;li&gt;You have JDK (not only JRE) installed on your machine (from &lt;a href=&quot;http://java.sun.com&quot;&gt;http://java.sun.com&lt;/a&gt;).&lt;/li&gt;
  &lt;li&gt;You have Eclipse installed on your machine (from &lt;a href=&quot;http://www.eclipse.org&quot;&gt;http://www.eclipse.org&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Case Study&lt;/h2&gt;

&lt;p&gt;
We will create our final application in multiple steps. Here's the brief overview of these steps:
&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;#gvaish37-step1&quot;&gt;Step 1&lt;/a&gt;: Create a window that contains a text that reads &amp;quot;Hello, World!&amp;quot;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#gvaish37-step2&quot;&gt;Step 2&lt;/a&gt;: Create a window that has a button on click of which we get launch other window with a text that reads, &amp;quot;Hello, World!&amp;quot;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
And the &amp;quot;top level window&amp;quot; with a &amp;quot;Title Bar&amp;quot;, &amp;quot;Minimize&amp;quot;, &amp;quot;Maximize&amp;quot; and &amp;quot;Close&amp;quot; buttons - the one that interacts with the Desktop or &amp;quot;Window Manager&amp;quot; - is known as &lt;code&gt;Shell&lt;/code&gt; in SWT.
&lt;/p&gt;

&lt;h2&gt;Getting Started - Creating Project&lt;/h2&gt;

&lt;p&gt;
We start by creating a project using Eclipse IDE. Follow these steps to create and configure a simple Java application project.
&lt;/p&gt;

&lt;p&gt;
Step 1: In the &amp;quot;New Project&amp;quot; wizard, select &amp;quot;Java Project&amp;quot;. Click Next.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/eclipse/swt/37.Eclipse.SWT.Hello.World-01.New.Project.jpg&quot; alt=&quot;Eduzine: Eclipse: SWT: Project&quot; title=&quot;Eduzine: Eclipse: SWT: Project&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Step 2: Give the name of the project - &amp;quot;HelloWorldSWT&amp;quot;. Click Next.
&lt;/p&gt;
&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/eclipse/swt/37.Eclipse.SWT.Hello.World-02.New.Project.Name.jpg&quot; alt=&quot;Eduzine: Eclipse: SWT: Project&quot; title=&quot;Eduzine: Eclipse: SWT: Project&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Step 3: Go to the &amp;quot;Libraries&amp;quot; Tab. Click &amp;quot;Add External Jars...&amp;quot; button.
&lt;/p&gt;
&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/eclipse/swt/37.Eclipse.SWT.Hello.World-03.Libraries.jpg&quot; alt=&quot;Eduzine: Eclipse: SWT: Project&quot; title=&quot;Eduzine: Eclipse: SWT: Project&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Step 4: Browse to the &amp;quot;plugins&amp;quot; folder within the folder where Eclipse is installed. Add references to &lt;code&gt;org.eclipse.swt_&amp;lt;version&amp;gt;.jar&lt;/code&gt; and &lt;code&gt;org.eclipse.swt.win32.win32.x86_&amp;lt;version&amp;gt;.jar&lt;/code&gt;. Click Finish.
&lt;/p&gt;
&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/eclipse/swt/37.Eclipse.SWT.Hello.World-04.Updated.jpg&quot; alt=&quot;Eduzine: Eclipse: SWT: Project&quot; title=&quot;Eduzine: Eclipse: SWT: Project&quot; /&gt;
&lt;/p&gt;

&lt;h2&gt;Entry Point&lt;/h2&gt;

&lt;p&gt;
Now that we have the project, let us create a class &lt;code&gt;HelloWorldClass&lt;/code&gt; that will act as the entry point (through the &lt;code&gt;main&lt;/code&gt; method) for our application.
&lt;/p&gt;
&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/eclipse/swt/37.Eclipse.SWT.Hello.World-05.HelloWorldClass.jpg&quot; alt=&quot;Eduzine: Eclipse: SWT: Add HelloWorldClass&quot; title=&quot;Eduzine: Eclipse: SWT: Add HelloWorldClass&quot; /&gt;
&lt;/p&gt;

&lt;a name=&quot;gvaish37-step1&quot;&gt;&lt;h2&gt;Implementation: Step 1&lt;/h2&gt;&lt;/a&gt;

&lt;p&gt;
Let's get started with the implementation. The first thing that we will ever need to create the UI is an instance of &lt;code&gt;org.eclipse.swt.widgets.Display&lt;/code&gt;. The top-level window, as discussed earlier, is an instance of &lt;code&gt;org.eclipse.swt.widgets.Shell&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
Update the code for &lt;code&gt;HelloWorldClass&lt;/code&gt; to as follows:
&lt;/p&gt;

&lt;pre&gt;package com.edujinilabs.eduzine.eclipse.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 &lt;strong&gt; Part of the Eduzine (http://eduzine.edujini-labs.com) Articles.
 &lt;/strong&gt; Downloads available at http://downloads.edujini-labs.com
 &lt;strong&gt; (C) 2008, Edujini Labs Pvt Ltd.
 &lt;/strong&gt; http://www.edujini-labs.com
 */
public class HelloWorldClass
{
  public static void main(String[] args)
  {
    Display display = new Display();
    Shell mainWindow = new Shell(display, SWT.DIALOG_TRIM);

    mainWindow.setText(&amp;quot;Eduzine: SWT Hello World&amp;quot;);
    mainWindow.open();
  }
}
&lt;/pre&gt;

&lt;p&gt;
Right click on the file and select &amp;quot;Run As...&amp;quot; -&amp;gt; &amp;quot;SWT Application&amp;quot;.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/eclipse/swt/37.Eclipse.SWT.Hello.World-06.Launch.jpg&quot; alt=&quot;Eduzine: Eclipse: SWT: Launch Main Class&quot; title=&quot;Eduzine: Eclipse: SWT: Launch Main Class&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
While launching, keep a close eye on the monitor. What do you see?
&lt;/p&gt;

&lt;p&gt;
Ouch! The new windows seems to be launched but also lost somewhere. &lt;img src=&quot;http://eduzine.edujini-labs.com/templates/default/img/emoticons/sad.png&quot; alt=&quot;:-(&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Well, if that's the case... you are on absolutely correct track! &lt;img src=&quot;http://eduzine.edujini-labs.com/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
The reason for this behaviour is that the &lt;code&gt;open&lt;/code&gt; method is a non-blocking call meaning that it opens up the window and returns immediately. And in our code, nobody stops the controls to get transferred past-end of the &lt;code&gt;main&lt;/code&gt; causing the application to terminate.
&lt;/p&gt;

&lt;p&gt;
So, the next step is to add the code that does the following:
&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Waits indefinitely, only to be terminated if we click the close [X] button on the title-bar of the main window.&lt;/li&gt;
  &lt;li&gt;Does not use CPU cycles if no activity is to be performed.&lt;/li&gt;
  &lt;li&gt;Respond to events, if there is any activity and again go for indefinite wait.&lt;/li&gt;
  &lt;li&gt;On closing the main window, it frees up the resources used, especially OS resources like Font, Color, Pen/Brush etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The loop that does the first-three steps mentioned above is known as &lt;em&gt;event loop&lt;/em&gt;.
&lt;/p&gt;

&lt;p&gt;
Update the &lt;code&gt;main&lt;/code&gt; method to the following code:
&lt;/p&gt;

&lt;pre&gt;public class HelloWorldClass
{
  public static void main(String[] args)
  {
    Display display = new Display();
    Shell mainWindow = new Shell(display, SWT.DIALOG_TRIM);

    mainWindow.setText(&amp;quot;Eduzine: SWT Hello World&amp;quot;);
    mainWindow.open();

    &lt;b&gt;while(!mainWindow.isDisposed())
    {
      if(!display.readAndDispatch())
      {
        display.sleep();
      }
    }
    display.dispose();&lt;/b&gt;
  }
}
&lt;/pre&gt;

&lt;p&gt;
Launch the application again. Not posting the screenshot since it's a huge window. &lt;img src=&quot;http://eduzine.edujini-labs.com/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
The next step is to add a text on the window that reads &amp;quot;Hello, World!&amp;quot;. We make use of the Widget named &lt;code&gt;Label&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
The constructors of all basic widgets require the information about the parent container in which they will be placed - the containers referred to as &lt;code&gt;Composite&lt;/code&gt; widgets. The second parameter to the constructor is a number (integer) representing the styles. We will explore the styles soon. So, what are we waiting for? Let's update the code... And ah! We shall resize the window to a smaller size.
&lt;/p&gt;

&lt;pre&gt;public class HelloWorldClass
{
  public static void main(String[] args)
  {
    Display display = new Display();
    Shell mainWindow = new Shell(display, SWT.DIALOG_TRIM);

    &lt;b&gt;Label hwLabel = new Label(mainWindow, SWT.NONE);
    hwLabel.setText(&amp;quot;Hello, World!&amp;quot;);&lt;/b&gt;

    mainWindow.setText(&amp;quot;Eduzine: SWT Hello World&amp;quot;);
    &lt;b&gt;mainWindow.setSize(300, 200);&lt;/b&gt;
    mainWindow.open();

    while(!mainWindow.isDisposed())
    {
      if(!display.readAndDispatch())
      {
        display.sleep();
      }
    }
    display.dispose();
  }
}
&lt;/pre&gt;

&lt;p&gt;
Things look much better now except only that we are yet, unable to see the &lt;code&gt;Label&lt;/code&gt;.
&lt;/p&gt;

&lt;h2&gt;Layout Manager&lt;/h2&gt;

&lt;p&gt;
All &lt;code&gt;Composite&lt;/code&gt; widgets use a layout manager - technically a subclass of &lt;code&gt;org.eclipse.swt.layout.GridLayout&lt;/code&gt; - to layout the child widgets within themselves.
&lt;/p&gt;

&lt;p&gt;
For our purpose, we make use of &lt;code&gt;org.eclipse.swt.layout.GridLayout&lt;/code&gt;. We explore it later on. Update the code to as follows:
&lt;/p&gt;

&lt;pre&gt;    Display display = new Display();
    Shell mainWindow = new Shell(display, SWT.DIALOG_TRIM);

    &lt;b&gt;GridLayout layout = new GridLayout();
    mainWindow.setLayout(layout);&lt;/b&gt;

    Label hwLabel = new Label(mainWindow, SWT.NONE);
    hwLabel.setText(&amp;quot;Hello, World!&amp;quot;);
&lt;/pre&gt;

&lt;p&gt;
Launch the application! Voila! Got the &amp;quot;Hello, World!&amp;quot;. The expected output is as below:
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/eclipse/swt/37.Eclipse.SWT.Hello.World-07-Layout.jpg&quot; alt=&quot;Eduzine: Eclipse: SWT: Specify Layout, Final Output&quot; title=&quot;Eduzine: Eclipse: SWT: Specify Layout, Final Output&quot; /&gt;
&lt;/p&gt;

&lt;a name=&quot;gvaish37-step2&quot;&gt;&lt;h2&gt;Implementation - Step 2&lt;/h2&gt;&lt;/a&gt;

&lt;p&gt;
Now that we've got a simple but working application, let's move on to the next step, making it interactive. We replace the &lt;code&gt;Label&lt;/code&gt; with a &lt;code&gt;org.eclipse.swt.widgets.Button&lt;/code&gt; and popup a new window that reads, &amp;quot;Hello, World!&amp;quot;
&lt;/p&gt;

&lt;p&gt;
Firstly, we replace &lt;code&gt;Label&lt;/code&gt; with &lt;code&gt;Button&lt;/code&gt;. Update the code to as follows:
&lt;/p&gt;

&lt;pre&gt;package com.edujinilabs.eduzine.eclipse.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
&lt;b&gt;import org.eclipse.swt.widgets.Button;&lt;/b&gt;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class HelloWorldClass
{
  public static void main(String[] args)
  {
    Display display = new Display();
    Shell mainWindow = new Shell(display, SWT.DIALOG_TRIM);

    GridLayout layout = new GridLayout();
    mainWindow.setLayout(layout);

    &lt;b&gt;Button hwBtn = new Button(mainWindow, SWT.NONE);
    hwBtn.setText(&amp;quot;Say Hello&amp;quot;);&lt;/b&gt;

    mainWindow.setText(&amp;quot;Eduzine: SWT Hello World&amp;quot;);
    mainWindow.setSize(300, 200);
    mainWindow.open();

    while(!mainWindow.isDisposed())
    {
      if(!display.readAndDispatch())
      {
        display.sleep();
      }
    }
    display.dispose();
  }
}
&lt;/pre&gt;

&lt;p&gt;
Subsequently, we create a class &lt;code&gt;HelloWorldWindow&lt;/code&gt; with similar UI as created earlier. However, this time, the new class will have a new method &lt;code&gt;open&lt;/code&gt; that will actually launch the UI. The definition of the class is as follows:
&lt;/p&gt;

&lt;pre&gt;package com.edujinilabs.eduzine.eclipse.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class HelloWorldWindow
{
  private Shell window;

  public HelloWorldWindow(Shell parent)
  {
    this.window = new Shell(parent, SWT.DIALOG_TRIM);

    GridLayout layout = new GridLayout();
    window.setLayout(layout);

    Label hwBtn = new Label(window, SWT.NONE);
    hwBtn.setText(&amp;quot;Hello, World!&amp;quot;);

    window.setText(&amp;quot;Eduzine: Child&amp;quot;);
    window.setSize(200, 100);
  }

  public void open()
  {
    this.window.open();
  }
}
&lt;/pre&gt;

&lt;p&gt;
Now, the only missing link is to launch this window on the click of the button! What are we waiting for then? Let's do it! Update &lt;code&gt;HelloWorldClass&lt;/code&gt; to as follows:
&lt;/p&gt;

&lt;pre&gt;  public static void main(String[] args)
  {
    Display display = new Display();
    &lt;b&gt;final&lt;/b&gt; Shell mainWindow = new Shell(display, SWT.DIALOG_TRIM);

    GridLayout layout = new GridLayout();
    mainWindow.setLayout(layout);

    Button hwBtn = new Button(mainWindow, SWT.NONE);
    hwBtn.setText(&amp;quot;Say Hello&amp;quot;);

    &lt;b&gt;hwBtn.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e)
      {
        HelloWorldWindow w = new HelloWorldWindow(mainWindow);
        w.open();
      }
    });
    &lt;/b&gt;
    ...
  }
&lt;/pre&gt;

&lt;p&gt;
On launch, the output expected is follows (Hey! Don't forget to click the button).
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/eclipse/swt/37.Eclipse.SWT.Hello.World-08-Button-Launch.jpg&quot; alt=&quot;Eduzine: Eclipse: SWT: Child Window&quot; title=&quot;Eduzine: Eclipse: SWT: Child Window&quot; /&gt;
&lt;/p&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;
In this article, we learnt how to get started with Standard Widget Toolkit, the UI Toolkit created for initially for Eclipse and now used by millions of developers worldwide!
&lt;/p&gt;

&lt;p&gt;
In subsequent articles, we explore about SWT and Eclipse, and environment around them.
&lt;/p&gt;
    </content:encoded>
    <pubDate>Wed, 25 Jun 2008 15:58:16 -0700</pubDate>
    <guid isPermaLink="false">http://eduzine.edujini-labs.com/archives/37-guid.html</guid>
    </item>
<item>
    <title>Google Web Toolkit says, &quot;Hello, World!&quot; - Part 2</title>
    <link>http://eduzine.edujini-labs.com/archives/28-Google-Web-Toolkit-says,-Hello,-World!-Part-2.html</link>
<category>JavaScript</category><category>Ajax</category><category>GWT</category><category>Web 2.0</category><category>&quot;Hello, World!&quot;</category>    <comments>http://eduzine.edujini-labs.com/archives/28-Google-Web-Toolkit-says,-Hello,-World!-Part-2.html#comments</comments>
    <wfw:comment>http://eduzine.edujini-labs.com/wfwcomment.php?cid=28</wfw:comment>
    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://eduzine.edujini-labs.com/rss.php?version=2.0&amp;type=comments&amp;cid=28</wfw:commentRss>
    <author>eduzine@edujinionline.com (Eduzine)</author>
    <content:encoded>

&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;
In the second article in the series - Google Web Toolkit says, &amp;quot;Hello, World!&amp;quot; - we learn how to do the same stuff in, probably, a more structured manner: use Eclipse IDE to write the code, compile and launch. So that we don't have to switch across the Java editor, command prompt and the browser.
&lt;/p&gt;

&lt;p&gt;And the code - available at downloads in the &lt;a href=&quot;http://downloads.edujini-labs.com/index.php?act=category&amp;id=26&quot;&gt;GWT&lt;/a&gt; category.
&lt;/p&gt; 
&lt;h2&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;
The software required are:
&lt;/p&gt;&lt;ul&gt;
	&lt;li&gt;Java SDK from &lt;a href=&quot;http://java.sun.com/javase&quot;&gt;Sun Java&lt;/a&gt; Website&lt;/li&gt;
	&lt;li&gt;Eclipse IDE from &lt;a href=&quot;http://www.eclipse.org&quot;&gt;Eclipse&lt;/a&gt; website. If you are confused what to download, get the Eclipse IDE for Java EE developers &lt;a href=&quot;http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/europa/winter/eclipse-jee-europa-winter-win32.zip&quot;&gt;directly from here&lt;/a&gt;.&lt;/li&gt;
	&lt;li&gt;Google Web Toolkit from &lt;a href=&quot;http://code.google.com/webtoolkit/&quot;&gt;Google Code&lt;/a&gt; Website&lt;/li&gt;
	&lt;li&gt;Apache Tomcat from &lt;a href=&quot;http://tomcat.apache.org&quot;&gt;Apache&lt;/a&gt; Website&lt;/li&gt;
	&lt;li&gt;Cypal Studio &lt;a href=&quot;http://www.cypal.in/studio&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

&lt;/p&gt;&lt;h2&gt;Step 1: Creating Web Application&lt;/h2&gt;

&lt;p&gt;
First step is to create a &amp;quot;Dynamic Web Project&amp;quot; in Eclipse.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-01.NewProject.jpg&quot; alt=&quot;create a &quot; title=&quot;create a &quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Choose Web -&amp;gt; Dynamic Web Project.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-02.DWP.jpg&quot; alt=&quot;create a &quot; title=&quot;create a &quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Select appropriate Web Server Runtime - the &amp;quot;Target Runtime&amp;quot;. [If the only entry that you get is &amp;lt;none&amp;gt;, create a &amp;quot;New...&amp;quot; one. Point it to the Apache Tomcat folder.] From the &amp;quot;Configurations&amp;quot;, select &amp;quot;Cypal Studio GWT Project&amp;quot;.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-03.Cypal.Config.jpg&quot; alt=&quot;create a &quot; title=&quot;create a &quot; /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-04.Cypal.Facet.jpg&quot; alt=&quot;create a &quot; title=&quot;create a &quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Finally, provide a meaningful &amp;quot;Context Root&amp;quot;, or leave it as it.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-05.Web.Config.jpg&quot; alt=&quot;create a &quot; title=&quot;create a &quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Open the &amp;quot;Project Explorer&amp;quot; view. You should see similar to as shown below.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-06.Project.Explorer.jpg&quot; alt=&quot;create a &quot; title=&quot;create a &quot; /&gt;
&lt;/p&gt;

&lt;h2&gt;Step 2: Adding a Module&lt;/h2&gt;

&lt;p&gt;
Our web application is now ready. What we now need is to add the &amp;quot;HelloWorld&amp;quot; module as what we did through the &lt;code&gt;applicationCreator.cmd&lt;/code&gt; utility earlier. However, this time we will use the GUI.
&lt;/p&gt;

&lt;p&gt;
We need to add a new &amp;quot;GWT Module&amp;quot; to our application. Follow these steps:
&lt;/p&gt;

&lt;p&gt;
&lt;/p&gt;&lt;ul&gt;
&lt;li&gt;
Add a new item:&lt;br /&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-07.AddItem.jpg&quot; alt=&quot;Eclipse: Add a New Item&quot; title=&quot;Eclipse: Add a New Item&quot; /&gt;
&lt;/li&gt;
&lt;li&gt;
Add a new Module:&lt;br /&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-08.Module.jpg&quot; alt=&quot;Eclipse: Add a New Item&quot; title=&quot;Eclipse: Add a New Item&quot; /&gt;
&lt;/li&gt;
&lt;li&gt;
Give the name of the package as &lt;code&gt;com.edujinilabs.tutorials.gwt.hw&lt;/code&gt; (note that there is no &lt;code&gt;'client'&lt;/code&gt; as we had earlier), and the name of the class as &lt;code&gt;HelloWorld&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

&lt;/p&gt;&lt;p&gt;
The module has been added. The following artifacts would have been generated:
&lt;/p&gt;&lt;ul&gt;
	&lt;li&gt;Module definition file: &lt;code&gt;com/edujinilabs/tutorials/gwt/hw/HelloWorld.gwt.xml&lt;/code&gt;&lt;/li&gt;
	&lt;li&gt;HTML file: &lt;code&gt;com/edujinilabs/tutorials/gwt/hw/public/HelloWorld.html&lt;/code&gt;&lt;/li&gt;
	&lt;li&gt;Implementation Code: &lt;code&gt;com/edujinilabs/tutorials/gwt/hw/client/HelloWorld.java&lt;/code&gt;&lt;/li&gt;
	&lt;li&gt;Empty package &lt;code&gt;com.edujinilabs.tutorials.gwt.hw.server&lt;/code&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;

&lt;/p&gt;&lt;h2&gt;Step 3: Hello World Implementation&lt;/h2&gt;

&lt;p&gt;
We, now, have the skeleton to push in our code. What we shall do is have a simple &lt;code&gt;Button&lt;/code&gt; on the click of which we shall show a simple &lt;code&gt;alert&lt;/code&gt;. Update the class &lt;code&gt;HelloWorld&lt;/code&gt; to the following code:
&lt;/p&gt;

&lt;pre&gt;package com.edujinilabs.tutorials.gwt.hw.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

public class HelloWorld implements EntryPoint
{
    public void onModuleLoad()
    {
        Button helloBtn = new Button();
        helloBtn.setText(&amp;quot;Say Hello&amp;quot;);

        helloBtn.addClickListener(new ClickListener() {
            public void onClick(Widget sender)
            {
                Window.alert(&amp;quot;Hello, World!&amp;quot;);
            }
        });

        RootPanel.get().add(helloBtn);
    }
}
&lt;/pre&gt;

&lt;h2&gt;Step 4: Launching the Application&lt;/h2&gt;

&lt;p&gt;
We need to configure two things to launch and run the application. First, create a new &amp;quot;Run&amp;quot; configuration. Go to Run -&amp;gt; Run..., and follow these steps:
&lt;/p&gt;

&lt;p&gt;
&lt;/p&gt;&lt;ul&gt;
&lt;li&gt;
Add a new configuration:&lt;br /&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-12.Run.Configurations.jpg&quot; alt=&quot;Eclipse: Add a New Run Configuration for GWT&quot; title=&quot;Eclipse: Add a New Run Configuration for GWT&quot; /&gt;
&lt;/li&gt;
&lt;li&gt;
Provide a meaningful name to the configuration. Choose the project (if not already chosen) and the module.&lt;br /&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-13.New.Configuration.jpg&quot; alt=&quot;Eclipse: Add a New Run Configuration for GWT&quot; title=&quot;Eclipse: Add a New Run Configuration for GWT&quot; /&gt;
&lt;/li&gt;
&lt;li&gt;
Select the &amp;quot;Parameters&amp;quot; tab and configure the memory to be provided on the heap:&lt;br /&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-14.RAM.Configuration.jpg&quot; alt=&quot;Eclipse: Add a New Run Configuration for GWT&quot; title=&quot;Eclipse: Add a New Run Configuration for GWT&quot; /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

&lt;/p&gt;&lt;p&gt;
Click, optionally &lt;code&gt;Apply&lt;/code&gt; and then, &lt;code&gt;Run&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
Voila! We again the got the Google Web Toolkit Development Shell! Great, isn't it - noting that we did not touch anything outside Eclipse IDE this time.
&lt;/p&gt;

&lt;p&gt;
What next? Click on the button and &amp;quot;Say Hello&amp;quot;. &lt;img src=&quot;http://eduzine.edujini-labs.com/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/28.GWT.HelloWorld-Cypal-15.Output.jpg&quot; alt=&quot;Google Web Toolkit says, &quot; title=&quot;Google Web Toolkit says, &quot; /&gt;
&lt;/p&gt;


&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;
We can use the Cypal Studio plug-in for Eclipse to ease our life working with GWT. Well, of course, the power lies with GWT.
&lt;/p&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    </content:encoded>
    <pubDate>Tue, 27 May 2008 15:31:49 -0700</pubDate>
    <guid isPermaLink="false">http://eduzine.edujini-labs.com/archives/28-guid.html</guid>
    </item>
<item>
    <title>Google Web Toolkit says, &quot;Hello, World!&quot; - Part 1</title>
    <link>http://eduzine.edujini-labs.com/archives/27-Google-Web-Toolkit-says,-Hello,-World!-Part-1.html</link>
<category>JavaScript</category><category>Ajax</category><category>GWT</category><category>Web 2.0</category><category>&quot;Hello, World!&quot;</category>    <comments>http://eduzine.edujini-labs.com/archives/27-Google-Web-Toolkit-says,-Hello,-World!-Part-1.html#comments</comments>
    <wfw:comment>http://eduzine.edujini-labs.com/wfwcomment.php?cid=27</wfw:comment>
    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://eduzine.edujini-labs.com/rss.php?version=2.0&amp;type=comments&amp;cid=27</wfw:commentRss>
    <author>eduzine@edujinionline.com (Eduzine)</author>
    <content:encoded>

&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;
Google Web Toolkit (from Google, at &lt;a href=&quot;http://code.google.com/webtoolkit/&quot;&gt;Google Code&lt;/a&gt;) is a fantastic framework with a very interesting concept - write in Java run in JavaScript! This article demonstrates how to get started with Google Web Toolkit.
&lt;/p&gt;

&lt;p&gt;
The first part of the article demonstrates how to use the default tools provided in GWT to write the &amp;quot;Hello World&amp;quot; application. The second in the series will demonstrate how to use &lt;a href=&quot;http://www.cypal.in/studio&quot;&gt;Cypal Studio Plug-in&lt;/a&gt; for &lt;a href=&quot;http://www.eclipse.org&quot;&gt;Eclipse&lt;/a&gt; to make your life easy when it comes to creating, compiling and running GWT applications.
&lt;/p&gt;

&lt;p&gt;As usual, the code is available in the &lt;a href=&quot;http://downloads.edujini-labs.com&quot;&gt;Downloads&lt;/a&gt; section. Direct link to the Google Web Toolkit category is &lt;a href=&quot;http://downloads.edujini-labs.com/index.php?act=category&amp;id=26&quot;&gt;here&lt;/a&gt;.

&lt;/p&gt; 
&lt;h2&gt;What you need to know&lt;/h2&gt;

&lt;p&gt;
You will need to know Java, at the least because, as I mentioned earlier, majority of the code is written in Java. And please, no generics.
&lt;/p&gt;

&lt;h2&gt;Step 1: Getting Started&lt;/h2&gt;

&lt;p&gt;
Well, the first step is to download Java SDK, if you already don't have one. And then, you will need GWT.
&lt;/p&gt;

&lt;p&gt;
Here's the list, bulleted:
&lt;/p&gt;&lt;ul&gt;
	&lt;li&gt;Java SDK from &lt;a href=&quot;http://java.sun.com/javase&quot;&gt;Sun Java&lt;/a&gt; Website&lt;/li&gt;
	&lt;!--
	&lt;li&gt;Eclipse IDE from &lt;a href='http://www.eclipse.org'&gt;Eclipse&lt;/a&gt; website. If you are confused what to download, get the Eclipse IDE for Java EE developers &lt;a href='http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/europa/winter/eclipse-jee-europa-winter-win32.zip'&gt;directly from here&lt;/a&gt;.&lt;/li&gt;
	--&gt;
	&lt;li&gt;Google Web Toolkit from &lt;a href=&quot;http://code.google.com/webtoolkit/&quot;&gt;Google Code&lt;/a&gt; Website&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

&lt;/p&gt;&lt;p&gt;I don't think there should be any trouble to download and install.&lt;/p&gt;

&lt;br /&gt;

&lt;h2&gt;Step 2: Looking at GWT&lt;/h2&gt;

&lt;p&gt;
Browse to the folder where you extracted Google Web Toolkit. The folder structure should be similar to shown below.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/01.GWT.HelloWorld-01-Folder-Structure.jpg&quot; title=&quot;Folder Structure of Google Web Toolkit&quot; alt=&quot;Folder Structure of Google Web Toolkit&quot; /&gt;
&lt;/p&gt;

&lt;br /&gt;

&lt;h2&gt;Step 3: Creating GWT Application&lt;/h2&gt;

&lt;p&gt;
The very first step that you will do with GWT, after all installation, is to create a GWT Application.
&lt;/p&gt;

&lt;p&gt;
If you look at the files, you will notice a file &lt;code&gt;applicationCreator.cmd&lt;/code&gt;. You guessed it right, that's our starting point.
&lt;/p&gt;

&lt;p&gt;
At the command prompt, go the folder and issue the following command:
&lt;/p&gt;

&lt;pre&gt;applicationCreator.cmd -out gwt-hello-world com.edujinilabs.tutorials.gwt.hw.clent.HelloWorld
&lt;/pre&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/01.GWT.HelloWorld-02-ApplicationCreator.jpg&quot; alt=&quot;Google Web Toolkit; applicationCreator.cmd -out gwt-hello-world com.edujinilabs.tutorials.gwt.hw.client.HelloWorld&quot; title=&quot;Google Web Toolkit; applicationCreator.cmd -out gwt-hello-world com.edujinilabs.tutorials.gwt.hw.client.HelloWorld&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
You will notice a set of files created for you.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/01.GWT.HelloWorld-03-CreatedFiles.jpg&quot; alt=&quot;Google Web Toolkit; applicationCreator.cmd -out gwt-hello-world com.edujinilabs.tutorials.gwt.hw.client.HelloWorld; Created Files&quot; title=&quot;Google Web Toolkit; applicationCreator.cmd -out gwt-hello-world com.edujinilabs.tutorials.gwt.hw.client.HelloWorld; Created Files&quot; /&gt;
&lt;/p&gt;

&lt;br /&gt;

&lt;h2&gt;Step 4: Launching Application in 'Hosted' Mode&lt;/h2&gt;

&lt;p&gt;
Descend into the folder &lt;code&gt;gwt-hello-world&lt;/code&gt;. You will notice two files - &lt;code&gt;HelloWorld-compile.cmd&lt;/code&gt; and &lt;code&gt;HelloWorld-shell.cmd&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/01.GWT.HelloWorld-04-FolderHW.jpg&quot; title=&quot;Google Web Toolkit; Hello World&quot; alt=&quot;Google Web Toolkit; Hello World&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Launch &lt;code&gt;HelloWorld-shell.cmd&lt;/code&gt;. You will notice two windows opened - one titled &amp;quot;Google Web Toolkit Development Shell / Port 8888&amp;quot; and the other titled &amp;quot;Wrapper HTML for HelloWorld&amp;quot;.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/01.GWT.HelloWorld-05-WindowOne.jpg&quot; alt=&quot;Google Web Toolkit Development Shell / Port 8888&quot; title=&quot;Google Web Toolkit Development Shell / Port 8888&quot; /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/01.GWT.HelloWorld-06-WindowTwo.jpg&quot; alt=&quot;Wrapper HTML for HelloWorld&quot; title=&quot;Wrapper HTML for HelloWorld&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
In the second window, click the button that reads &amp;quot;Click me&amp;quot;. Voila! It says, &amp;quot;Hello World!&amp;quot;.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/01.GWT.HelloWorld-07-SayHello.jpg&quot; alt=&quot;Google Web Toolkit says, &quot; title=&quot;Google Web Toolkit says, &quot; /&gt;
&lt;/p&gt;

&lt;h2&gt;Where's the code?&lt;/h2&gt;

&lt;p&gt;
If you go into the folder &lt;code&gt;gwt-hello-world/src/com/edujinilabs/tutorials/gwt/hw/client&lt;/code&gt;, you will notice &lt;code&gt;HelloWorld.java&lt;/code&gt;. Yes, that's where the original code is.
&lt;/p&gt;

&lt;h2&gt;Where's the JavaScript?&lt;/h2&gt;

&lt;p&gt;
Ok! I agree. Browsers do not, yet, natively run Java code. So, where's the JavaScript? It's hidden right now. Let's generate.
On the command prompt, issue the following command (in the same folder as where you issued &lt;code&gt;HelloWorld-shell.cmd&lt;/code&gt;:
&lt;/p&gt;

&lt;pre&gt;HelloWorld-compile.cmd
&lt;/pre&gt;

&lt;p&gt;
&lt;img src=&quot;http://eduzine.edujini-labs.com/uploads/technology/javascript/gwt/01.GWT.HelloWorld-08-Compile.jpg&quot; alt=&quot;Google Web Toolkit; HelloWorld-compile.cmd&quot; title=&quot;Google Web Toolkit; HelloWorld-compile.cmd&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Descend into the folder &lt;code&gt;www/com.edujinilabs.tutorials.gwt.hw.HelloWorld&lt;/code&gt;. You will notice two files - &lt;code&gt;HelloWorld.html&lt;/code&gt; and &lt;code&gt;com.edujinilabs.tutorials.gwt.hw.HelloWorld.nocache.js&lt;/code&gt;. Now, that's where the code is.
&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;
Well, without getting into even a single line of code, we have been able to say, &amp;quot;Hello World!&amp;quot; using Google Web Toolkit. We have been able to get a peek into where the original Java code resides, and where do we get the compiled / generated JavaScript and HTML content.
&lt;/p&gt;

&lt;p&gt;
We shall explore Google Web Toolkit in greater depth in next articles. Keep watching the category &lt;a href=&quot;http://eduzine.edujini-labs.com/categories/20-GWT&quot;&gt;Google Web Toolkit / GWT&lt;/a&gt;
&lt;/p&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;

    </content:encoded>
    <pubDate>Mon, 26 May 2008 15:34:00 -0700</pubDate>
    <guid isPermaLink="false">http://eduzine.edujini-labs.com/archives/27-guid.html</guid>
    </item>
</channel>
</rss>
