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

📄 right5_2_2.htm

📁 清华大学JAVA教程
💻 HTM
字号:
<html><head><title>JAVA编程语言</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><link rel="stylesheet" href="../../../css/text.css" type="text/css"></head><body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" ><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">  <tr>     <td valign="top">       <table width="97%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">        <tr>          <td valign="top">             <p> <span class="pt9-black">  例如,与键盘事件KeyEvent相对应的接口是:<br>                public interface KeyListener extends EventListener {<br>                   public void keyPressed(KeyEvent ev);<br>                   public void keyReleased(KeyEvent ev);<br>                   public void keyTyped(KeyEvent ev);<br>                }<br>              <br>                注意到在本接口中有三个方法,那么java运行时系统何时调用哪个方法?其实根据这三个方法的方法名就能够知道应该是什么时候调用哪个方法执行了。当键盘刚按下去时,将调用keyPressed(               )方法执行,当键盘抬起来时,将调用keyReleased( )方法执行,当键盘敲击一次时,将调用keyTyped( )方法执行。</span></p>            <p class="pt9-black">  又例如窗口事件接口: <br>                public interface WindowListener extends EventListener{<br>                   public void windowClosing(WindowEvent e); <br>                   <font color="339900">//把退出窗口的语句写在本方法中</font><br>                   public void windowOpened(WindowEvent e); <br>                   <font color="339900">//窗口打开时调用</font><br>                   public void windowIconified(WindowEvent e); <br>                   <font color="339900">//窗口图标化时调用</font><br>                   public void windowDeiconified(WindowEvent e); <br>                   <font color="339900">//窗口非图标化时调用</font><br>                   public void windowClosed(WindowEvent e);<br>                   <font color="339900">//窗口关闭时调用</font><br>                   public void windowActivated(WindowEvent e); <br>                   <font color="339900">//窗口激活时调用</font><br>                   public void windowDeactivated(WindowEvent e); <br>                   <font color="339900">//窗口非激活时调用</font><br>                }</p>            <p class="pt9-black">  AWT的组件类中提供注册和注销监听器的方法:<br>              <br>                <b>◇ 注册监听器:</b><br>                public void add&lt;ListenerType&gt; (&lt;ListenerType&gt;listener);<br>              <br>                <b>◇ 注销监听器:</b><br>                public void remove&lt;ListenerType&gt; (&lt;ListenerType&gt;listener);</p>            <p class="pt9-black">  例如Button类:(查API)<br>                public class Button extends Component {<br>                   ……<br>                   public synchronized void addActionListener(ActionListener l);<br>                   public synchronized void removeActionListener(ActionListener               l);<br>                   ……}</p>            </td>        </tr>      </table>    </td>  </tr></table></body></html>

⌨️ 快捷键说明

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