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

📄 netconnectapplet.java

📁 JAVA分布式程序学习的课件(全英文)
💻 JAVA
字号:
// A generic Applet
// When run in a browser or an appletviewer, it displays
// the string "Hello World"


import java.applet.Applet;
import java.awt.*;

import java.net.*;
import java.io.*;

public class NetConnectApplet extends Applet {
    public void paint(Graphics g) {
        Font myFont = new Font("Serif", Font.BOLD, 25);
        g.setColor(Color.red);
        g.drawString("Running an applet:", 50, 25);

        try {
           Socket socket;
           // attempt to make a network connection to www.alpha.edu
           socket = new Socket("www.alpha.edu", 80 );
           g.drawString("Opened a socket to www.csc.calpoly.edu port 80:", 
           50, 45);
//*
           // attempt to make a network connection to www.beta.edu
           socket = new Socket("www.beta.edu", 80 );
           g.drawString("Opened a socket to www.calpoly.edu port 80:", 
           50, 45);
//*/
        }
        catch (Exception ex)
        { 
            ex.printStackTrace( );
        }
         
    } //end paint
} //end class

⌨️ 快捷键说明

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