This listener responds to mouse events - movement and button presses
It's a pretty simple example
class Demo extends Label implements MouseListener
{
Timer t = new Timer()
{
public void run()
{
DOM.setStyleAttribute(getElement(), "backgroundColor", "white");
}
};
public Demo()
{
setStyleName("table-center");
setText("Mouse Over And Click");
setSize("200px","200px");
DOM.setStyleAttribute(getElement(), "textAlign", "center");
DOM.setStyleAttribute(getElement(), "border", "5px solid #ddd");
addMouseListener(this);
}
public void onMouseDown(Widget sender, int x, int y)
{
DOM.setStyleAttribute(getElement(), "borderColor", "#f00");
}
public void onMouseEnter(Widget sender)
{
DOM.setStyleAttribute(getElement(), "borderColor", "#0f0");
}
public void onMouseLeave(Widget sender)
{
DOM.setStyleAttribute(getElement(), "borderColor", "#ddd");
}
public void onMouseMove(Widget sender, int x, int y)
{
DOM.setStyleAttribute(getElement(), "backgroundColor", "yellow");
t.schedule(300);
}
public void onMouseUp(Widget sender, int x, int y)
{
DOM.setStyleAttribute(getElement(), "borderColor", "#0f0");
}
}