Java 移动鼠标时工具提示消息

Java 移动鼠标时工具提示消息,java,gwt,tooltip,Java,Gwt,Tooltip,当我将鼠标移到图像上时,我试图显示一个弹出框。你能帮忙吗 public shopWidget extends Composite implements ClickListener { Image phoneImage = new Image(); Image serviceImage = new Image(); FlexTable flTable = new FlexTable(); flTable.setWidget(0, 0, this.rewardsLabel);

当我将鼠标移到图像上时,我试图显示一个弹出框。你能帮忙吗

public shopWidget extends Composite implements ClickListener {
   Image phoneImage = new Image();
   Image serviceImage = new Image();
   FlexTable flTable = new FlexTable();
   flTable.setWidget(0, 0, this.rewardsLabel);
   flTable.setWidget(1, 0, this.serviceImage);
   this.initWidget(flTable);
}

如果你用的是swing,看起来不像,那我为什么要回答?然后,所有JComponents都隐式支持工具提示,方法如下:

setToolTipText(String text)
这里很简单,gwt在任何UIObject(包括图像)上显示弹出文本。这是浏览器固有的,只允许使用文本

final PopupPanel pop = new PopupPanel(false, false);
pop.setWidget(new Label("popup"));
Image image = new CustomTooltipImage(pop);
image.setUrl("http://sstatic.net/stackoverflow/img/venn-diagram.png");
以下是自定义工具提示图像类:

public class CustomTooltipImage extends Image implements MouseOverHandler, MouseMoveHandler, MouseOutHandler
{
    private final PopupPanel tooltip;

    public CustomTooltipImage(PopupPanel tooltip)
    {
        super();
        this.tooltip = tooltip;
        addMouseOverHandler(this);
        addMouseOutHandler(this);
        addMouseMoveHandler(this);
    }

    @Override
    public void onMouseOut(MouseOutEvent event)
    {
        tooltip.hide();
    }

    @Override
    public void onMouseMove(MouseMoveEvent event)
    {
        tooltip.setPopupPosition(event.getClientX(), event.getClientY());
    }

    @Override
    public void onMouseOver(MouseOverEvent event)
    {
        tooltip.setPopupPosition(event.getClientX(), event.getClientY());
        tooltip.show();
    }
}

什么操作系统、图形用户界面、编程语言、平台、环境等?请至少适当地标记。当鼠标从图像图标移开时,弹出窗口必须淡出/消失。请帮助查看我不需要Windoe。提醒我已设计了我的owm自定义弹出窗口。让我告诉我如何使弹出窗口消失我从该图像移开‘事情是我能够显示弹出窗口,我将鼠标放在上面当我将鼠标移开时,图像不会消失。如果我单击附近的某个位置,图像会消失。获取更多方法检查javadoc。这是onmouseOver处理程序的基础。然后你根据自己的需要改变一切什么是PopupPanel?
public class CustomTooltipImage extends Image implements MouseOverHandler, MouseMoveHandler, MouseOutHandler
{
    private final PopupPanel tooltip;

    public CustomTooltipImage(PopupPanel tooltip)
    {
        super();
        this.tooltip = tooltip;
        addMouseOverHandler(this);
        addMouseOutHandler(this);
        addMouseMoveHandler(this);
    }

    @Override
    public void onMouseOut(MouseOutEvent event)
    {
        tooltip.hide();
    }

    @Override
    public void onMouseMove(MouseMoveEvent event)
    {
        tooltip.setPopupPosition(event.getClientX(), event.getClientY());
    }

    @Override
    public void onMouseOver(MouseOverEvent event)
    {
        tooltip.setPopupPosition(event.getClientX(), event.getClientY());
        tooltip.show();
    }
}