MessageClient2.java



/** Messageの通信のクライアント */
import java.awt.*;
import java.net.*;
import java.rmi.*;
public class MessageClient2 {

  /** 起動時に呼び出されるメソッド */
    public static void main( String argv[] ) {

        System.setSecurityManager( new RMISecurityManager() );
        try {
            String serverName = "rmi://" + argv[0] + "/TalkServer";

            InetAddress host = InetAddress.getLocalHost();
            String hostName = host.getHostName();
            String receiverName = "rmi://" + hostName + "/MessageReceiver";

            MessageMonitor monitor
              = new MessageMonitor( serverName, receiverName );
            MessageSendField sender
              = new MessageSendField( serverName, hostName );
            QuitButton button
              = new QuitButton( serverName, receiverName );

            Frame frame = new Frame( "Message Client" );
            frame.add( sender.panel, "North" );
            frame.add( monitor.panel, "Center" );
            frame.add( button, "South" );
            frame.pack();
            frame.show();
         }
         catch( Exception e ) {
            System.out.println( "Error:" + e.toString() );
            System.exit(-1);
         }
    }
}