Source Code : extends PopupPanel to create Tooltip
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
extends PopupPanel to create Tooltip
package com.java2s.gwt.client;
import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.core.client.*;
public class GWTClient implements EntryPoint{
public void onModuleLoad() {
Label label = new Label();
label.setText("label with tooltip");
label.addMouseListener(new MouseListenerAdapter() {
public void onMouseEnter(Widget sender) {
ToolTip tip = new ToolTip("this is a tooltip.",0,0);
}
public void onMouseLeave(Widget sender) {
}
public void onMouseDown(Widget sender, int x, int y) {
}
public void onMouseUp(Widget sender, int x, int y) {
}
});
RootPanel.get().add(label);
}
}
class ToolTip extends PopupPanel{
final int VISIBLE_DELAY = 2000;
Timer removeDelay;
public ToolTip(String message, int x, int y){
super(true);
this.setPopupPosition(x, y);
this.add(new Label(message));
removeDelay = new Timer(){
public void run() {
ToolTip.this.setVisible(false);
ToolTip.this.hide();
}
};
removeDelay.schedule(VISIBLE_DELAY);
this.addPopupListener(new PopupListener(){
public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
removeDelay.cancel();
}
});
this.setStyleName("toolTip");
this.show();
}
public boolean onEventPreview(Event event){
int type = DOM.eventGetType(event);
switch(type){
case Event.ONMOUSEDOWN:
case Event.ONCLICK:{
this.hide();
return true;
}
}
return false;
}
}
Thank with us