Work with mouse Listener : MouseListener « GWT « Java






Work with mouse Listener



package com.java2s.gwt.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.Grid;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;


public class GWTClient implements EntryPoint{
     /**
    * This is the entry point method.
    */
   public void onModuleLoad() {

        // Create Label widget
      final Label roller = new Label("Default value");

        // Associate HTML element to GWT widget
      RootPanel.get().add(roller);

        // Add mouse lister to label widget
      roller.addMouseListener(new MouseListener() {
         public void onMouseEnter(Widget sender) {
            roller.setText("Entered element...");
         }

         public void onMouseLeave(Widget sender) {
            roller.setText("Leaving element...");
         }

         // Do nothing
         public void onMouseDown(Widget sender, int x, int y) {}

         // Do nothing
         public void onMouseMove(Widget sender, int x, int y) {}

         // Do nothing
         public void onMouseUp(Widget sender, int x, int y) {}
      });
   }
}

           
       








GWT-mouseListener.zip( 3 k)

Related examples in the same category

1.implements SourcesMouseEvents