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

📄 1.htm

📁 javaapplet的几个比较好的例子 适合初学者 javaapplet主要用于网页,实现一些插件的功能
💻 HTM
字号:
<html><!-- #BeginTemplate "/Templates/empolder_doc.dwt" -->
<head>
<!-- #BeginEditable "doctitle" --> 
<title>|&gt;&lt;| 太平洋电脑信息网 -&gt; 网络学院 -&gt; 开发教室</title>
<!-- #EndEditable --> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
-->
</style>
<link rel="stylesheet" href="/pcedu/style/text.css"></head>

<body bgcolor="#FFFFFF" topmargin=0 leftmargin=0 marginheight="0">
<script language="JavaScript" src="/pcedu/script/top.js">
</script>
<table width=760 border=0 cellspacing=0 cellpadding=0 align=center>
  <tr> 
    <td width=194 height="56"><a href=http://www.pconline.com.cn><img src=http://www.pconline.com.cn/images/pconlinelogo.gif width=162 height=35 vspace=10 border=0></a></td>
    <td width=406 height="56">
      <script language="JavaScript" src="/pcedu/script/empolder_ad.js">
</script>
    </td>
    <td width=158 align=right height="56">
      <script language="JavaScript" src="/pcedu/script/empolder_ad1.js">
</script>
    </td>
    <td align=right width=2 height="56">&nbsp;</td>
  </tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=760 align="center">
  <tbody> 
  <tr valign=bottom> 
    <td rowspan=2 width=172><img height=32 src="/pcedu/images/pcedu_lo.gif" 
      width=172 border="0"></td>
    <td height=30 rowspan=2> 
      <table cellpadding=0 cellspacing=0 width="588" bgcolor="#FFA000" background="/pcedu/images/e_menu5.gif" border="0">
        <tbody> 
        <tr valign="bottom"> 
          <td height="17"> 
            <script language="JavaScript" src="/pcedu/script/title_empolder.js">
</script>
          </td>
        </tr>
        </tbody> 
      </table>
    </td>
  </tr>
  <tr></tr>
  <tr bgcolor="#303880"> 
    <td colspan=2 height=1 valign=bottom><img height=1 
      src="/pcedu/images/blank.gif" width=1></td>
  </tr>
  <tr> 
    <td colspan=2 height=5 valign=bottom><img height=5 
      src="/pcedu/images/blank.gif" width=1></td>
  </tr>
  </tbody> 
</table>
<table width="760" cellspacing="0" cellpadding="0" align="center" height="37">
  <tr> 
    <td width="170" valign="top"> 
      <table border="0" width="170" height="100%"
    cellspacing="1" bgcolor="#000000">
        <tr bgcolor="#F8F8D2"> 
          <td width="100%" valign="top"><!-- #BeginEditable "left" --> 
            <div align="center"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" align="center">
                <tr bgcolor="#E17329"> 
                  <td height="20" align="center"><font color="#FFFFFF">==<b>开发教室==</b></font></td>
                </tr>
              </table>
              <br>
            </div>
            <!-- #EndEditable -->
            <script language="JavaScript" src="/pcedu/script/left_empolder.js">
</script>
          </td>
        </tr>
      </table>
    </td>
    <td width="10"><img src="/pcedu/images/blank.gif" width="1" height="1"></td>
    <td width="580" valign="top" class="article"> 
      <p><img src="/pcedu/images/666666.gif" width="99%" height="1"></p>
      <!-- #BeginEditable "content" --> 
      <p align="center"><span class="title">Java Applet 入门</span></p>
      <p align="right"><a href="mailto:yy435@263.net">yy435</a></p>
      <p align="right">太平洋网络学院</p>
      <p align="center" class="green">第四天</p>
      <p align="left" class="green">鼠标和键盘事件处理函数</p>
      <p>所谓事件,就是指在系统中有某些我们所关心的事情(例如:鼠标移动了,用户按下了某个按键……等)发生了,然后系统便通知我们去处理这些事情。这样的概念在一般采用窗口用户界面环境的操作系统中,是十分常见的。</p>
      <p>在Java中,所有的事件都定义在类Event(java.awt.Event)内,读者有兴趣的话,可以参考Java的API。</p>
      <p><font color="#66FF66">1)鼠标事件。</font></p>
      <p>鼠标时间一般有:<br>
        <font color="#FF9966">mouseDown:</font>当鼠标的按键被用户按下时,就会发生MOUSE_DOWN时间,这个时候系统便调用方法mouseDown对该事件进行处理。方法mouseDown的写法为:</p>
      <p>public boolean mouseDown(Event e,int x,int y)<br>
        {<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;……<br>
        }</p>
      <p>由上面可知,方法mouseDown有三个参数:e,x,y。e就是事件本身,我们把“事件”看成一个对象实体,只不过它的类是Event而已,同时,事件在使用上和一般的对象实体没有差别。而x,y则是这个时间发生时的鼠标的坐标值。要注意的是它的方法返回值是boolean型的值,这点要注意!另外,由于有些机器的鼠标只有一个按键,考虑到Java的与平台无关性,因此,这个方法中,就没有我们常见的右键的功能了。它不区分左右按键。 
      </p>
      <p><font color="#FF9966">mouseUp:</font>与前面的相反,这个方法是鼠标放开时的处理函数了,对于使用方法,与mouseDown完全相同。这儿就不多说了!</p>
      <p><font color="#FF9966">mouseMove:</font>MOUSE_MOVE和MOUSE_DRAG都是由鼠标移动产生的事件,方法mouseMove就是用来处理MOUSE_MOVE事件的。方法为:</p>
      <p>public boolean mouseMove(Event evt,int x,int y)<br>
        {<br>
        …… <br>
        }</p>
      <p>所用到的参数和方法mouseDown和mouseUp的完全一样。</p>
      <p><font color="#FF9966">mouseDrag:</font>从上面知道,这个方法当然是用来处理MOUSE_DRAG事件的。方法为:</p>
      <p>public boolean mouseDrag(Event e,int x,int y)<br>
        {<br>
        ……<br>
        }</p>
      <p><font color="#FF9966">mouseEnter:</font>这个方法是用来处理MOUSE_ENTER事件的,当鼠标进入到小应用程序的窗口范围时,就会发生MOUSE_ENTER事件。处理方法为 
        :</p>
      <p>public boolean(Event evt, int x,int y)<br>
        {<br>
        ……<br>
        }</p>
      <p>所用到的参数和前面一样,不多说了。</p>
      <p><font color="#FF9966">mouseExit:</font>这个方法是用来处理MOUSE_EXIT事件的。当鼠标从小应用程序窗口移出来的时候,就会发生MOUSE_EXIT事件了。处理方法为:</p>
      <p>public boolean (Event e,int x,int y)<br>
        {<br>
        ……<br>
        } </p>
      <p>好了,让我们来看一看具体的例子:[<a style="text-decoration: none"href="#" onclick="window.open('11.htm','1','menubar=no,toolbar=1,location=no,directories=no,status=no,resizable=1,scrollbars=1,width=780,height=440,top=20,left=10');">请点击这儿进入</a>]</p>
      <p><font color="#99FF99">2)键盘事件:</font><br>
        和鼠标比起来,键盘产生的时间就简单多了,一般说来,我们关心的就是用户按下了什么键,再处理就行了,而不必像鼠标那样还具有移动的事件要处理。它的主要事件有:</p>
      <p>KEY_PRESS:按下键时产生;<br>
        KEY_RELEASE:放开键盘按键的时候产生。处理它们方法方法分别为:</p>
      <p> public boolean keyDown(Event evt,int x,int y)<br>
        {<br>
        ……<br>
        }</p>
      <p>public loolean keyUp(Event evt,int x,int y)<br>
        {<br>
        ……<br>
        }</p>
      <p>参数中的evt还是表示事件本身的对象,而key就是那个被用户按下或放开的案件。Java已经在类Event中,定义好一些表转的按键值,如下:</p>
      <table width="100%" border="1" bordercolor="#000000">
        <tr> 
          <td width="112"><font color="#000000">类变量</font></td>
          <td width="174"><font color="#000000">代表的按键</font></td>
          <td width="143"><font color="#000000">类变量</font></td>
          <td width="143"><font color="#000000">代表的按键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.Up</font></td>
          <td width="174"><font color="#000000">方向键中的“上”键</font></td>
          <td width="143"><font color="#000000">Event.F3</font></td>
          <td width="143"><font color="#000000">“F3”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.DOWN</font></td>
          <td width="174"><font color="#000000">方向键中的“下”键</font></td>
          <td width="143"><font color="#000000">Event.F4</font></td>
          <td width="143"><font color="#000000">“F4”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.LEFT</font></td>
          <td width="174"><font color="#000000">方向键中的“左”键</font></td>
          <td width="143"><font color="#000000">Event.F5</font></td>
          <td width="143"><font color="#000000">“F5”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.RIGHT</font></td>
          <td width="174"><font color="#000000">方向键中的“右”键</font></td>
          <td width="143"><font color="#000000">Event.F6</font></td>
          <td width="143"><font color="#000000">“F6”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.HOME</font></td>
          <td width="174"><font color="#000000">“Home”键</font></td>
          <td width="143"><font color="#000000">Event.F7</font></td>
          <td width="143"><font color="#000000">“F7”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.END</font></td>
          <td width="174"><font color="#000000">“End”键</font></td>
          <td width="143"><font color="#000000">Event.F8</font></td>
          <td width="143"><font color="#000000">“F8”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.PGUP</font></td>
          <td width="174"><font color="#000000">“Page Up”键</font></td>
          <td width="143"><font color="#000000">Event.F9</font></td>
          <td width="143"><font color="#000000">“F9”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.PGDN</font></td>
          <td width="174"><font color="#000000">“Page Down”键</font></td>
          <td width="143"><font color="#000000">Event.F10</font></td>
          <td width="143"><font color="#000000">“F10”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.F1</font></td>
          <td width="174"><font color="#000000">“F1”键</font></td>
          <td width="143"><font color="#000000">Event.F11</font></td>
          <td width="143"><font color="#000000">“F11”键</font></td>
        </tr>
        <tr> 
          <td width="112"><font color="#000000">Event.F2</font></td>
          <td width="174"><font color="#000000">“F2”键</font></td>
          <td width="143"><font color="#000000">Event.F12</font></td>
          <td width="143"><font color="#000000">“F12”键</font></td>
        </tr>
      </table>
      <p align="center"><a href="../03/16.htm">[上一页]</a> <a href="11.htm">[下一页]</a></p>
      <!-- #EndEditable --> 
      <table width="100%" border="0">
          <tr class="sfont"> 
            <td>
              <div align="center"><a href="javascript:history.go(-1)">[返回]</a>
              </div>
            </td>
          </tr>
        </table>
      </td>
  </tr>
</table>
<hr noshade size="2" width="760">
<div align="center"> 
  <p align="center"><font color="#000000"> 
    <script language="JavaScript" src="/pcedu/script/title_edu.js">
</script>
    </font> <br>
    <br>
    版权所有&copy;2000 太平洋电脑网<br>
    <font face="Arial, Helvetica, sans-serif"> 
    <script>
document.write("<a href=http://best.netease.com/cgi-bin/view/viewbasic.cgi?exp target=_blank><img src=http://best.netease.com/cgi-bin/log.cgi?user=exp&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" border=0 alt='网易中文排行榜' width=1 height=1></a>");
</script>
    <a href=mailto:webmaster@pconline.com.cn> </a></font><font face="Arial, Helvetica, sans-serif"><a href=mailto:webmaster@pconline.com.cn>webmaster@pconline.com.cn</a></font><font face="Arial, Helvetica, sans-serif"><a href=mailto:webmaster@pconline.com.cn> 
    <script language="">document.write("<a href=http://best.netease.com/cgi-bin/view/viewbasic.cgi?pconline1 target=_blank><img src=http://best.netease.com/cgi-bin/log.cgi?user=pconline1&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" border=0 width=1 height=1 ></a>");</script>
    </a> 
    <script language="">
document.write("<a href=http://count.pconline.com.cn/admin/index.php target=_blank><img src=http://count.pconline.com.cn/count.php?user=pcedu&refer="+escape(document.referrer)+" border=0 width=0 height=0 alt='' ></a>");
</script>
    </font> </p>
    </div>
 
</body>
<!-- #EndTemplate --></html>

⌨️ 快捷键说明

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