【问题标题】:in GWT, change the background of Label when mouseover在 GWT 中,鼠标悬停时更改标签的背景
【发布时间】:2013-04-08 04:28:50
【问题描述】:

我得到了这个代码:

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");

但是什么也没发生,那么我的代码出了什么问题?

谁能帮我解决它?

【问题讨论】:

    标签: gwt user-interface label mouseover


    【解决方案1】:

    您需要将鼠标处理程序注册到 Label。

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

    【讨论】:

    • 实际上应该是lb.addMouse...(lb) 而不是this
    【解决方案2】:
    label.addStyleName("labelStyle");
    
    .labelStyle : Hover {
    
     background : url("Mention your image");
    
    }
    

    【讨论】:

      【解决方案3】:

      请在颜色代码前面保留#

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-07-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多