Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在GWT中,鼠标悬停时更改标签的背景_Gwt_User Interface_Label_Mouseover - Fatal编程技术网

在GWT中,鼠标悬停时更改标签的背景

在GWT中,鼠标悬停时更改标签的背景,gwt,user-interface,label,mouseover,Gwt,User Interface,Label,Mouseover,我得到了这个密码: 私有类MyLabel扩展标签实现MouseOverHandler、MouseOutHandler{ MouseOver上的公共无效(最终鼠标覆盖moe){ this.getElement().getStyle().setBackgroundColor(“E6D5D5”); } @凌驾 MouseOut上的公共无效(MouseOutEvent事件){ //TODO自动生成的方法存根 这个.getElement().getStyle().setBackgroundColor(“F

我得到了这个密码:

私有类MyLabel扩展标签实现MouseOverHandler、MouseOutHandler{
MouseOver上的公共无效(最终鼠标覆盖moe){
this.getElement().getStyle().setBackgroundColor(“E6D5D5”);
}
@凌驾
MouseOut上的公共无效(MouseOutEvent事件){
//TODO自动生成的方法存根
这个.getElement().getStyle().setBackgroundColor(“FFFFFF”);
}
}
MyLabel lb=新的MyLabel();
lb.setText(“ok”);
但是什么都没发生,那么我的代码怎么了


有人能帮我修复吗?

您需要注册鼠标处理程序来标记

lb.addMouseOverHandler(this);
lb.addMouseOutHandler(this);

请将#放在颜色代码前面

实际上它将是
lb.addMouse…(lb)
而不是
label.addStyleName("labelStyle");

.labelStyle : Hover {

 background : url("Mention your image");

}