如何使用 GWT 设置和/或处理 onload 事件 [英] How do I setup for and/or handle onload event with GWT

查看:17
本文介绍了如何使用 GWT 设置和/或处理 onload 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这必须是一个非常基本的问题,但我一生都无法通过 Google 或本网站找到任何有关如何执行此操作的信息,这真的很令人沮丧,因为我已经阅读了 GWT 教程.

This has to be a pretty basic question but I cannot for the life of me find anything via Google or this site about how to do this and it's really frustrating because I've gone through the GWT tutorial.

我正在尝试将我必须的 javascript 项目转换为 GWT.现在我正在尝试将 "" 转换为 GWT 等效的内容.我查看了 RootPanel,但什么也看不到.

I'm trying to convert a javascript project I have to GWT. Right now I am trying to convert "" to something GWT equivalent. I've looked at RootPanel and I can't see anything.

显然我遗漏了 GWT 中的一些基本内容?!

Obviously I'm missing something fundamental in GWT ?!

推荐答案

GWT 中的大多数小部件和面板都实现了 HasAttachHandlers 接口.向这些小部件/面板添加一个 AttachEvent.Handler 相当于定义一个函数来运行 onload.

Most widgets and panels in GWT implements the HasAttachHandlers interface. Adding an AttachEvent.Handler to these widgets/panels is equivalent to defining a function to run onload.

示例:

FlowPanel mainPanel = new FlowPanel();
mainPanel.addAttachHandler(new AttachEvent.Handler() {

  @Override
  public void onAttachOrDetach(AttachEvent event) {
    // do something
  }
});

这篇关于如何使用 GWT 设置和/或处理 onload 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆