[an error occurred while processing this directive]

Creating Hyperlink using GWT


This example describes the Basics for building the Hyperlink using GWT. The steps involved in Building the Hyperlink are described below:-

private Label label = new Label()
Here we are declaring label. Label is a widget that contains text.

Hyperlink link0 = new Hyperlink("Delhi", "Delhi")
Creating Hyperlink object named 'link0'. Hyperlink is a class or a widget that serves as an "internal" hyperlink

VerticalPanel panel = new VerticalPanel()
Creating Vertical panel. Vertical panel  is a class that lays all of its widgets out in a single vertical column.

This is the method of  class Vertical panel. By using this method we added a label to the Panel

History is a class that allows us to interact with the browser's history stack. addHistoryListener() is a method of this class to adds a listener to the browser's history stack.


package org.yournamehere.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.HistoryListener;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class HyperLinkExample implements EntryPoint,HistoryListener {
  private Label label = new Label();
   public void onModuleLoad() {
    Hyperlink link0 = new Hyperlink("Delhi""Delhi");
    Hyperlink link1 = new Hyperlink("Mumbai""Mumbai");
    Hyperlink link2 = new Hyperlink("Chennai""Chennai");
    Hyperlink link3 = new Hyperlink("Banglore""Banglore");

    String Token = History.getToken();
    if (Token.length() == 0) {
    VerticalPanel panel = new VerticalPanel();
  public void onHistoryChanged(String historyToken) {
    label.setText("The current Link selected is: " + historyToken);


<?xml version="1.0" encoding="UTF-8"?>
  <inherits name="com.google.gwt.user.User"/>
  <entry-point class="org.yournamehere.client.HyperLinkExample"/>

Output of the program

Download sourcecode


[an error occurred while processing this directive]