⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 13_4.htm

📁 翁剀JAVA语言那门课程的教案 很多人都看多他的视频教程可惜没有ppt的教案
💻 HTM
字号:
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Weng Kai">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.01 [en] (Win95; I) [Netscape]">
   <TITLE>Binding events dynamically</TITLE>
</HEAD>
<BODY>

<H2>
13.4 Binding events dynamically</H2>

<HR WIDTH="100%">
<BR>One of the benefits of the new AWT event model is flexibility. In the
old model you were forced to hard code the behavior of your program, but
with the new model you can add and remove event behavior with single method
calls. The following example demonstrates this:

<P>Case Study: <A HREF="case/DynamicEvents.java">DynamicEvents.java</A>

<P>The new twists in this example are:
<OL>
<LI>
There is more than one listener attached to each Button. Usually, components
handle events as multicast, meaning that you can register many listeners
for a single event. In the special components in which an event is handled
as unicast, you'll get a TooManyListenersException.</LI>

<LI>
During the execution of the program, listeners are dynamically added and
removed from the Button b2. Adding is accomplished in the way you've seen
before, but each component also has a removeXXXListener( ) method to remove
each type of listener. This kind of flexibility provides much greater power
in your programming. You should notice that event listeners are not guaranteed
to be called in the order they are added (although most implementations
do in fact work that way).</LI>
</OL>

<HR WIDTH="100%">
<DIV ALIGN=right><A HREF="13_5.htm">Next Page</A></DIV>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -