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

📄 index2a_page5.htm

📁 一个java的web的聊天的程序的客户端
💻 HTM
📖 第 1 页 / 共 2 页
字号:
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/internet/index.htm">Internet应用</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/photoshop/index.html">Photoshop</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/flash/page1.html">Flash</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/asp/index.html">ASP</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/php/index.html">PHP</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/java/index.htm">Java</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/vb/index.htm">VB</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/c/index.htm">C、C++</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-backend/database/php_mysql/index.html">PHP/MySQL</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2"><a href="../../1-backend/cgi_perl/perl_beginner/index.html">-Perl</a> 
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/other/index.htm">其它</a> </td>
  </tr>
  <tr> 
    <td colspan="2" bgcolor="#666699"> 
      <div align="center"><font color="#FFFFFF">更多教程</font></div>
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="17"><a href="../../1hdml/index.html">-HDML</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="23"><font face="宋体"><a href="../../1-backend/database/course/day1_1.html">-网络数据库</a></font></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="14"><a href="../../1-backend/protocols/ping/index.html"><font face="arial, helvetica, sans-serif">-ping</font></a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="20"><a href="../../1-backend/cgi_perl/search_engine/index.html">-创建搜索引擎</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="16">-<a href="../../1adobe/GoLive/index.html">Adobe GoLive</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2"><a href="../../1-backend/cgi_perl/templates/index.html">-模板</a></td>
  </tr>
  <tr bgcolor="#666699"> 
    <td colspan="2" align="center"><font color="#FFFFFF">合作伙伴</font></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" align="left">-<a href="http://www.5dmedia.com/" target="_blank">5D精英网</a></td>
  </tr>
  <tr align="center" bgcolor="#FFFFFF"> 
    <td colspan="2"> <img src="../../Library/front_monkey.gif" width="59" height="68"></td>
  </tr>
  </tbody> 
</table>
<!-- #EndLibraryItem --> </td>
 <!-- End of headlines (column 1: left column) --> <!-- Gutter between columns 1 and 2 --> 
 <td width="10" height="794"><img src="http://www.sohu.com/images/pixel.gif" width=10></td>
 <!-- Search box and directories (columns 2 and 3: middle columns, combined into one) --> 
 <td align=center valign=top width="558"> 
 <div align="left"><!-- #BeginEditable "1" --> 
              <table border="0" cellpadding="3" width="550" celspacing="0">
                <!-- AUTHOR IMAGE --> <!-- BUFFER --> 
                <tr> 
                  <td rowspan="2" width="12"><font face="宋体"><img
    src="http://static.wired.com/webmonkey/images/spacer.gif" width="10" height="1"></font></td>
                  <!-- HEADLINE --> 
                  <td width="494"><font color="#FF3300" size="4" face="宋体"><br>
                    </font><font face="宋体" color="#ff3300" size="5"><b><b>第5页: 
                    连接到闲聊服务器上</b></b></font><font face="宋体"><big><br>
                    </big>作者</font><a href="mailto:bslesins@best.com"
    title="Send
mail to Brian Slesinsky"><font color="#000000" size="3" face="宋体">Brian Slesinsky</font></a><big><font face="宋体"> 
                    </font></big></td>
                </tr>
                <!-- SEE ALSO LINKS --> 
                <tr> <!-- BODY COPY --> <!-- BUFFER --> 
                  <td valign="top" rowspan="2" width="494" bgcolor="#FFFFFF"><font size="3">现在我们已经有了一个用户界面,我们需要将其连接到闲聊服务<br>
                    器上。我们需要有一个套接口,要打开连接,我们需要知道闲聊<br>
                    服务器名称和断口的号码。最好使用小程序的参数,这样在改变<br>
                    参数时无需重新编译该小程序。 
                    <p>如果一个用户离开乐闲聊室,我们需要让闲聊室内的其他人知道<br>
                      该情况,所以用户离开该页面时小程序应该断开同闲聊服务器的<br>
                      连接。所以我们用小程序的<font face="宋体"><tt>start()</tt></font>和<font
    face="宋体"><tt>stop()</tt></font>方法断开和关闭套<br>
                      接口。 </p>
                    <p><font face="宋体"><b>Chat.java:</b> </font></p>
                    <pre><font face="宋体">
import java.applet.Applet;
import java.awt.*;<b>
import java.net.Socket;</b>

public class Chat extends Applet {
  TextArea ta;
  TextField tf;<b>
  Socket s;
</b>

  public void init() {
    ta = new TextArea(&quot;&quot;,20,80);
    ta.setEditable(false);
    add(ta);

    tf = new TextField(80);
    add(tf);
  }
<b>
  public void start() {
    try {
      String host = getParameter(&quot;host&quot;);
      int port = Integer.parseInt(getParameter(&quot;port&quot;));
      s = new Socket(host,port);
    } catch(Exception e) {
      ta.appendText(&quot;applet error: &quot;+e+&quot;\n&quot;);
    }
  }

  public void stop() {
    try {
      s.close();
    } catch(Exception e) {
      ta.appendText(&quot;applet error: &quot;+e+&quot;\n&quot;);
    }
  }
</b>
  public boolean handleEvent(Event e) {
    if(e.id==Event.ACTION_EVENT &amp;&amp; e.target==tf) {
      ta.appendText(tf.getText()+&quot;\n&quot;);
      tf.setText(&quot;&quot;);
      return true;
    }
    return false;
  }

}
</font></pre>
                    <p><font face="宋体"><b>index.html:</b> </font></p>
                    <pre><font face="宋体">
&lt;body bgcolor=&quot;#FFFFFF&quot;&gt;
&lt;applet code=&quot;Chat&quot; width=600 height=400&gt;<b>
&lt;param name=host value=&quot;somewhere.hotwired.com&quot;&gt;
&lt;param name=port value=&quot;2323&quot;&gt;</b>
[Chat applet]
&lt;/applet&gt;
&lt;/body&gt;
</font></pre>
                    <p><font face="宋体">(</font>这里是修改后的<a
    href="http://www.hotwired.com/webmonkey/code/97/24/applets/4.html" target="other">小程序</a>。<font
    face="宋体">) </font></p>
                    </font> 
                    <p><font size="3">第<font face="宋体">1</font>页:<a href="index.html">闲聊服务器的<font
    face="宋体">Java</font>客户端</a><br>
                      第<font face="宋体">2</font>页:</font><font size="3" face="宋体"><a
    href="index2a_page2.htm">'Hello World' 测试</a><b><br>
                      </b>第3页:<a href="index2a_page3.htm">设置该'Chat'的面貌</a><br>
                      第4页:<a href="index2a_page4.htm">处理Input事件</a><br>
                      第5页:<a href="index2a_page5.htm">连接到闲聊服务器上</a><br>
                      第6页:<a href="index2a_page6.htm">传输文本</a><br>
                      第7页:<a href="index2a_page7.htm">Java的移植性</a><br>
                      第8页:<a href="index2a_page8.htm">最后的工作</a><br>
                      </font>
                  </td>
                </tr>
              </table>
              <!-- #EndEditable --></div>
 </td>
 <!-- End of search box and directories (columns 2 and 3: middle columns, combined into one) --> 
 <!-- Gutter between columns 3 and 4 --> <!-- Other stuff (column 4: right column) --> 
 <!-- End of other stuff (column 4: right column) --> </tr>
 </table>
<!-- End of table surrounding page contents -->

 <hr noshade size=1 width=700>
 <span class=eng><br>
 Copyright (C) 1998-2000 Internet Technologies China.&nbsp; All rights reserved. 
 </span> 
</center>
</body>
<!-- #EndTemplate --></html>

⌨️ 快捷键说明

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