Class Pinglet

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----Pinglet

public class Pinglet
extends Applet
Example Applet to demonstrate Java sockets. Sends messages to the Java Demo Server on the host (port number 6666), and displays the replies.

Constructor Index

 o Pinglet()

Method Index

 o action(Event, Object)
Called each time something happens on the user interface.
 o init()
Applet initialisation method.
 o start()
Called each time the browser displays the page.
 o stop()
Called each time the browser leaves the page.

Constructors

 o Pinglet
  public Pinglet()

Methods

 o init
  public void init()
Applet initialisation method. We create our user interface which consists of a button and two text areas. We make sure that neither text area can be edited by the user, as they are for display only.
Overrides:
init in class Applet
 o start
  public void start()
Called each time the browser displays the page. This is where we create our socket, and obtain the data streams we need to talk through it. We make sure that our "ping" button is only enabled if we succeed in setting up the socket.
Overrides:
start in class Applet
 o stop
  public void stop()
Called each time the browser leaves the page. We disable our "ping" button and close down the socket.
Overrides:
stop in class Applet
 o action
  public boolean action(Event event,
                        Object arg)
Called each time something happens on the user interface. We only deal with the "ping" button here. When this is pressed we send a message through the socket to the server machine, and read the reply. The sent and received messages are displayed in our text areas.
Parameters:
event - Identifies what happened in the GUI
arg - The GUI object that was affected
Returns:
always "true" (shows we handled the event)
Overrides:
action in class Component