2

我正在为 GWT 应用程序搜索类似气球的小部件,例如在地图上显示搜索结果时 Google 地图显示的气球。

搜索时我只找到了 Javascript 小部件,但在 GWT 中没有任何小部件可以使用吗?

4

2 回答 2

3

看看OverLib。它是一个开源 javascript 库,用于显示增强的弹出提示窗口。它可以很容易地集成到 GWT 中。此外,您还可以自由创建自己的 HTML 弹出窗口。

这是我的 over lib 帮助程序代码的片段(必须将 overlib 解压缩到 GWT 项目的公共文件夹中)。使用getSimpleToolTip生成的属性只是添加到您的 GWT 元素中:

    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;
 }
于 2009-12-29T09:31:25.853 回答
2

在 GWT 中,借助弹出面板创建您自己的小部件。拥有像气球一样的图像(图像背景应该是透明的)并将其设置为弹出面板背景。之后根据您的要求添加您的结果,如“A”、“B”等...作为弹出面板中的标签。

于 2009-12-21T03:17:01.217 回答