GWT事件处理

package com.zly.client;



import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.DomEvent;
import com.google.gwt.event.dom.client.ErrorEvent;
import com.google.gwt.event.dom.client.ErrorHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.dom.client.MouseMoveEvent;
import com.google.gwt.event.dom.client.MouseMoveHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.dom.client.MouseUpHandler;
import com.google.gwt.event.dom.client.MouseWheelEvent;
import com.google.gwt.event.dom.client.MouseWheelHandler;
import com.google.gwt.event.dom.client.ScrollEvent;
import com.google.gwt.event.dom.client.ScrollHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.TreeListener;
import com.google.gwt.user.client.ui.Widget;



public class Test implements EntryPoint {

	@SuppressWarnings("deprecation")
	public void onModuleLoad() {
		
		Label label = new Label("Change event example:");
		add(label);
		final TextBox box = new TextBox();
		RootPanel.get().add(box);
		box.addChangeHandler(new ChangeHandler() {
			public void onChange(ChangeEvent event) {
				alert("change event occur");
			}
		});
		
		Label label2 = new Label("Click event example");
		add(label2);
		final Button[] btns = new Button[5];
		for (int i = 0; i < btns.length; i++) {
			btns[i] = new Button("Button" + i);
			add(btns[i]);
			final Button btn = btns[i];
			btns[i].addClickHandler(new ClickHandler() {
				public void onClick(ClickEvent event) {
					alert(btn.getText() + " " + " click event occur");
				}
			});
		}
		
		Label label3 = new Label("Focus event example");
		add(label3);
		final TextBox box2 = new TextBox();
		add(box2);
		box2.addFocusHandler(new FocusHandler() {
			public void onFocus(FocusEvent event) {
				box2.setText("got focus!");
			}
		});
		box2.addBlurHandler(new BlurHandler() {
			public void onBlur(BlurEvent event) {
				box2.setText("lost focus!");
			}
		});
		
		Label label4 = new Label("keyboard event example");
		add(label4);
		TextBox box3 = new TextBox();
		add(box3);
		box3.addKeyDownHandler(new KeyDownHandler() {
			public void onKeyDown(KeyDownEvent event) {
				alert("you press " + (char)event.getNativeKeyCode() + " down");
			}
		});
		
		box3.addKeyPressHandler(new KeyPressHandler() {
			public void onKeyPress(KeyPressEvent event) {
				alert("you press " + event.getCharCode());
			}
		});
		
		box3.addKeyUpHandler(new KeyUpHandler() {
			public void onKeyUp(KeyUpEvent event) {
				alert("you press " + (char)event.getNativeKeyCode() + " up");
			}
		});
		
		
		Label label5 = new Label("Image event example");
		add(label5);
		final Image image = new Image("xx.jpg");
		add(image);
		image.addLoadHandler(new LoadHandler() {
			public void onLoad(LoadEvent event) {
				
			}
		});
		image.addErrorHandler(new ErrorHandler() {
			public void onError(ErrorEvent event) {
				image.setTitle("no such image");
			}
		});
		
		HTML html = new HTML("<div></div>");
		html.setSize("300", "300");
		DOM.setStyleAttribute(html.getElement(), "border", "solid 1px");
		add(html);
		html.addMouseOverHandler(new MouseOverHandler() {
			public void onMouseOver(MouseOverEvent event) {
				alert("mouse over");
			}
		});
		
		html.addMouseMoveHandler(new MouseMoveHandler() {
			public void onMouseMove(MouseMoveEvent event) {
				alert(event.getClientX() + ":" + event.getClientY());
			}
		});
		
		html.addMouseOutHandler(new MouseOutHandler() {
			public void onMouseOut(MouseOutEvent event) {
				alert("mouse out");
			}
		});
		
		html.addMouseUpHandler(new MouseUpHandler() {
			public void onMouseUp(MouseUpEvent event) {
				alert("mouse up");
			}
		});
		
		ScrollPanel panel  = new ScrollPanel();
		panel.setSize("100", "30");
		panel.add(new Label("This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label.This is a label."));
		add(panel);
		panel.addScrollHandler(new ScrollHandler() {
			public void onScroll(ScrollEvent event) {
				box.setText("Scorll!!!");
			}
		});
		
		
		TextArea area = new TextArea();
		area.setSize("150", "150");
		area.setValue("This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.This is value.");
		area.addMouseWheelHandler(new MouseWheelHandler() {
			public void onMouseWheel(MouseWheelEvent event) {
				alert("mouse wheel occur!");
			}
		});
		add(area);

		
		final Grid grid = new Grid(3 , 3);
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				grid.setText(i, j, "Cell(" + i + " , " + j + ")");
			}
		}
		grid.setBorderWidth(1);
		add(grid);
		grid.addTableListener(new TableListener() {
			public void onCellClicked(SourcesTableEvents sender, int row,
					int cell) {
				DOM.setStyleAttribute(((Grid)(sender)).getCellFormatter().getElement(row, cell), "border", "3px solid #f00");
			}
		});
		
		
		Tree tree = new Tree();
		tree.addItem("Item1");
		tree.addItem("Item2");
		tree.addItem("Item3");
		tree.addItem("Item4");
		tree.addTreeListener(new TreeListener() {
			public void onTreeItemSelected(TreeItem item) {
				alert(item.getText() + " selected");
			}
			public void onTreeItemStateChanged(TreeItem item) {
				alert(item.getText() + " changed");
			}
		});
		add(tree);
	}
	public void add(Widget element) {
		RootPanel.get().add(element);
	}
	public void alert(String src) {
		Window.alert(src);
	}
	public String getEventType(DomEvent<?> event) {
		return event.toString();
	}
}

 

STM32 使用IO口模拟I2C时序 上一篇《I2C协议详解》 我们了解了I2C的操作流程,这一篇,我们就使用I2C,来对EEPROM进行操作吧。 我们做两种选择: 1.时序由IO口模拟高低电平,需要了解协议并按照协议操作相应的IO口。 2.时序由硬件自行产生,不需要人工干预; 由硬件产生的I2C时序,我们借助Stm32Cube配置实现便可,我们这一篇,抛开Stm32Cube,手撕代码,根据I2C的时序,一步步地实现I2C对... 阅读详情

相关推荐

采用了fluent模拟了平壁面结霜过程。udf,很经典,可以试试。

利用该模型作为FLUENT中的源项,模拟了在局部冷却下冷表面上的霜形成,以预测霜的形态、温度分布和霜的重量,结果与实验结果吻合良好。结果显示,霜首先围绕冷却块形成,然后逐渐向其他方向扩展,冷却块上方的霜密度最大。随着时间的推移,平均霜厚度逐渐增加,生长速率减慢,而平均霜密度随增长速率变快而增加。相变传递微观过程与机理、蒸发及冷凝换热、强化传热、高效传热管、热泵、制冷、节水节能新技术、电子元器件冷却、余热回收及梯级利用等。udf,很经典,可以试试。工程热物理、空调、热能、低温制冷、化工、物理等。

qq_15963745的博客 888

定时器setTimeout()、setInterval()详解

JavaScript 标准参考教程(alpha) 浏览器对象 定时器 GitHub  TOP  定时器 来自《JavaScript 标准参考教程(alpha)》,by 阮一峰 目录

风动之石的专栏 1万+

GWT入门与经典实例解析

不可多得的GWT资料,3分不多吧?百度上很少有相关资源

【译】GWT入门:构建用户界面

【译自:https://developers.google.com/web-toolkit/doc/latest/tutorial/buildui?hl=zh-CN】   到此,我们已经创建了StockWatcher工程,也审视了功能需求和界面元素。   这一切,我们要开始使用GWT提供的控件和面板来构建用户界面。   GWT已经处理了很多跨浏览器的兼容问题。因此,如果你是基于GWT...

刘刚的空间 501

gwt利用HandlerManager创建event事件

gwt利用HandlerManager创建event事件By 王军, 2010年02月1日 11:49 下午    在学习和使用gwt过程中,会使用到大量的事件处理,是利用各个组件的监听器来完成的,很方便。但是有些情况我们需要自己定义一个事件,用来创建监听器。就像下面例子中的,当点击删除时,在另一个类中创建了一个对话框,当点击确认之后要把此事件告送给当前类,那么就需要在当前类里面创建监

junpeng88的专栏 1582

GWT中的事件与监听器

GWT应用程序运行时,当用户单击鼠标或按下键盘,GWT都会产生一个事件来相应用户的请求。所谓事件就是指在应用程序中我们关心的某些事情发生了,然后应用程序去处理这些事件。对这些事件做出相应的程序就叫做事件处理器。 GWT所支持的事件和java有些不同,因为GWT是WEB应用程序,所有GWT所支持的事件应该是web浏览器事件GWT支持浏览器可以捕获的所有事件,GWT所能捕获的事件请参考com.go

T` 5034

gwt事件原理

GWT事件原理   1.事件处理方式 当浏览器html标签的事件被触发时,GWT会把事件的处理转发到Widget.onBrowserEvent(Event event)方法进行浏览器事件与GWT事件的转换,调用GWT中定义的事件处理!在此可以收集所有事件的相关信息!   2.GWT事件...

chensir1985的专栏 236

GWT中sinkEvent方法的用途

sinkEvent是指为GWT控件注册一些事件。比如TextBox会响应OnKeyPressed事件的原因是因为TextBox的实现中使用了sinkEvent(GWT实现)。sinkEvent对于我们的用处在于,当我们使用DOM方式或者继承Widget或者通过继承Composite实现Composite Widget时,可以将我们需要的一些Event通过sinkEvent...

weixin_34128534的博客 145

GWT 入门介绍

GWT 入门介绍GWT使用JSON格式的数据通讯  GWTGoogle Web Toolkit的简称。 GWT是一个以Java语言为工具,以类似Swing的方式编写UI组件,之后通过GWT Compiler编译 为JavaScritp和HTML在客户端浏览器中运行的一个开发工具和编程模型。  GWT应用程序有两种方式运行:Hosted Model     在

Struts 2 的专栏 3万+

gwt 实现界面模式之 "Extras on Demand"

GWT 是一个强大的工具, 一旦定义好html结构和css之后,使用gwt提供的组件模型,可以将任意结构的html+css封装成为组件 ,并在java 语言中以组件的方式操作.GWT 1.6 增加了新的事件系统(原有的事件api可能会在将来删除), 更使得在dom或者现有的组件之上扩展开发相当容易.下面将以一个例子说明如何使用新的事件模型扩展现有组件. (使用最新的 gwt 1.6.4 )...

imduker的专栏 254

GWT教程之 增加事件监听器

&lt;!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0...

shiren1118的专栏 435

现代GWT的第一步

The GWT context  GWT是强大的工具,但有时这种力量可能会被&#35270...

专业的开发者“讨论” 832

GWT入门

GWTGoogle Web Development Kit的缩写,可让程序员使用Java开发Ajax Web应用程序。 GWT编译器将Java代码转换为JavaScript和html代码。 GWT应用程序称为模块,并使用xml文件描述模块,假设该模块名称为xml文件的“ mymodule”名称为“ mymodule.gwt.xml”。 一个模块至少有一个入口点,它与Java程序中的main...

最佳 Java 编程 2035

gwt 测试_GWT应用程序的单元和集成测试

gwt 测试 GWTGoogle开发的框架,用于使用Java编程语言构建支持AJAX的Web应用程序。 它包括: 用于创建GUI的API(类似于Swing),用于处理Web浏览器的文档对象模型(DOM)。 Java到JavaScript的编译器。 用于运行和调试GWT应用程序的环境。 这种方法具有一些优点: 假设您了解Java,则无需学习新的编程语言。 您可以构建...

cunfu6353的博客 1266

上市公司-是否为高科技行业(1990-2024年),包含五种高科技行业分类方式,参考文献,代码,最终结果

1、资源内容地址:https://blog.csdn.net/2301_79696294/article/details/1535352322、数据特点:今年全新,手工精心整理,放心引用,数据来自权威,且标注《数据来源》,相对于其他人的控制变量数据准确很多,适合写论文做实证用 ,不会出现数据造假问题3、适用对象:大学生,本科生,研究生小白可用,容易上手!!!4、课程引用: 经济学,地理学,城市规划与城市研究,公共政策与管理,社会学,商业与管理

上一篇: GWT中各种Panel
下一篇: 中英文所占字节数
java_mail_test
博客等级 码龄17年 1粉丝 299原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值