import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; import java.awt.*; import java.awt.event.*; import java.net.InetAddress; public class PopupClientImpl extends UnicastRemoteObject implements PopupClientInterface{ String s; /** * Constructor , just calls the constructor for UnicastRemoteObject * Create and export a new UnicastRemoteObject object using an anonymous port */ PopupClientImpl() throws RemoteException{ super(); } /** *Shows the popup on the client in a new frame. *@param String containing the message to be brodcast. */ public void showPopup(String s) throws RemoteException{ final Frame f= new Frame(); // Create a new frame this.s=s; f.setSize(200,100); f.setTitle(s); f.add( new Label(s)); /* This adds the anonymous inner class to handle the closing of the frame by extending the windowAdapter and overriding the windowCloing method note the syntax may seem a little cryptic at first it follows the convention new Super{ ..... } where Super is an interface or a superclass. */ f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ f.dispose(); } }); f.setVisible(true); } /** *Returns some information about the individual client. *An ip address in our case, could also be a login name etc *@return String containing the IP address or login name */ public String getInfo() throws RemoteException{ try{ return InetAddress.getLocalHost().getHostAddress(); } catch(Exception e){ return e.toString();} } }