Reputation: 845
I got this code:
private class MyLabel extends Label implements MouseOverHandler, MouseOutHandler {
public void onMouseOver(final MouseOverEvent moe) {
this.getElement().getStyle().setBackgroundColor("E6D5D5");
}
@Override
public void onMouseOut(MouseOutEvent event) {
// TODO Auto-generated method stub
this.getElement().getStyle().setBackgroundColor("FFFFFF");
}
}
MyLabel lb=new MyLabel();
lb.setText("ok");
But nothing happened, so what wrong in my code?
Can anyone help me to fix it?
Upvotes: 2
Views: 2386
Reputation: 3380
label.addStyleName("labelStyle");
.labelStyle : Hover {
background : url("Mention your image");
}
Upvotes: 1
Reputation: 3673
You need to register mouse handlers to Label.
lb.addMouseOverHandler(this);
lb.addMouseOutHandler(this);
Upvotes: 4