import net.jini.core.entry.*;
import net.jini.core.lookup.*; 
import net.jini.core.discovery.*;    
import net.jini.lookup.entry.*; 
import com.sun.jini.lookup.*;
import java.rmi.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

/***************************************************************************

    MyServerApplet -- The Jini Server's Applet User Interface Object

 ***************************************************************************/

    public class MyServerApplet extends Applet
      implements ActionListener, Entry
      {
      Button b;                               
      public MyServerInterface myServerInterface;           // Must be public

      public MyServerApplet ()
        {
        // This constructor is needed.
        }

      public MyServerApplet (MyServerInterface myServerInterfaceIn)
        {
        myServerInterface = myServerInterfaceIn;
        }

      public void init ()
        {
        Label l;

        setLayout (new BorderLayout (0, 0));
        l = new Label ("MyServerApplet (delivered by Jini)", Label.CENTER);
        add ("North", l);
        b = new Button ("Press Button");
        b.addActionListener (this);
        b.setFont (new Font ("Helvetica", Font.BOLD | Font.ITALIC, 24));
        add ("Center", b);
        }

      public void actionPerformed (ActionEvent evt)        // ActionListener
        {
        if (evt.getSource () == b)
          {
          callServer ();
          }
        }

      void callServer ()
        {
        try
          {
          System.out.println ("applet: Return from sayHello() --->"
            + myServerInterface.sayHello () + "<---");
          }
        catch (Exception e)
          {
          System.out.println ("callServer(): exception: " + e);
          }
        }

      public String toString ()
        {
        return ("MyServerApplet[" + myServerInterface + "]");
        }
      }

