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

📄 remappletclient.java

📁 有关java的源程序,为讲授java程序设计课程使用
💻 JAVA
字号:
/* ******** The Applet Must be Execute by Appletviewer.exe *****
  C> appletviewer http://ServerIPAddress/RemAppletClient.html
*/
import java.rmi.*;
import java.net.*;
import java.io.*;
import java.applet.*;
import java.awt.*;

public class RemAppletClient extends Applet
{
	Rem remObject;
	public void init()
	{
    	try
		 {
/*
    "remObject" is the identifier that we'll use to refer to the remote 
	object that implements the "Rem"  interface

*/
		   remObject=(Rem)Naming.lookup("rmi://"+getCodeBase().getHost()+"/Rem");
		   
		 }
		 catch(RemoteException re)
		 {
			System.out.println("RemoteException:"+re);
		 }
 		 catch(NotBoundException nbe)
		 {
			System.out.println("NotBoundException:"+nbe);
		 }
		 catch(MalformedURLException mfe)
		 {
			System.out.println("MalformedURLException:"+mfe);
		 }

	}
	public void paint(Graphics g)
	{
		try
		 {
	       g.drawString(remObject.getMessage(),50,50);
		   remObject.setMessage("This Is RMI Applet Client Setted Message !");
		   g.drawString(remObject.getMessage(),50,150);
		 }
	     catch(RemoteException re)
		 {
			System.out.println("RemoteException:"+re);
		 }

	}
}

/*
1. First, the applet gets a reference to the remote object implementation 
  (advertised as "RemServer") from the server host's rmiregistry.Like the
  Naming.rebind method, the Naming.lookup method takes a URL-formatted 
  java.lang.String. In this example, the applet constructs the URL string by
  using the getCodeBase method in conjunction with the getHost method. 
  Naming.lookup takes care of the following tasks:

⌨️ 快捷键说明

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