views:

570

answers:

2

I'm searching for a balloon-like widget for a GWT application, e.g. like the balloons Google Maps shows when displaying search results on a map.

When searching I only found Javascript widgets, but aren't there any widgets to use in GWT?

+2  A: 

In GWT create your own widget with the help of popup panel.Have image like baloon (Image background should be transparent) and set it as a popup panel background.After that depends on your requirement add your results like "A","B",etc... as a label in popup panel.

BlackPanther
Well, it seems that it's not so easy: the tail of the baloon should point to a certain widget. If I use a fixed background image, this is not always the case, as PopupPanel.showRelativeTo() positions the Panel dynamically:"Depending on the width and height of the popup and the distance from the target to the bottom and right edges of the window, the popup may be displayed directly above the target, and/or its right edge may be aligned with the right edge of the target." (Source: http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/PopupPanel.html)
Bob
+3  A: 

Take a look at OverLib. It is an open source javascript lib to show enhanced pop up hint windows. It can be easy integrated into GWT. Plus you have the freedom to create you own HTML pop ups.

Here is a snippet of my over lib helper code (overlib must be unpacked into the public folder of your GWT project). The attributes produced with getSimpleToolTip are just added to your GWT elements:

    public static String getSimpleToolTip(String text, Integer width, Integer height)
 {
  String alt = "onmouseout=\"" + getOnMouseOutAttribute() + "\""; 
  alt = alt + " onmouseover=\"" + getOnMouseOverAttribute(text, width, height) + "\"";
  return alt;
 }

 public static String getOnMouseOutAttribute()
 {
  return "return nd();"; 
 }

 public static String getOnMouseOverAttribute(String text, Integer width, Integer height)
 {
  String out = "return overlib('" + text + "'";
  out = out + ", DELAY, 750";

  if (width != null)
  {
   out = out + ", WIDTH, " + width.toString();
  }

  if (height != null)
  {
   out = out + ", HEIGHT, " + height.toString();
  }

  out = out + ");";

  return out;
 }
Drejc