Example Applets and Applications

This release includes five example programs: All example are both applets and applications.

Chat

Chat is a simple chat program. It looks something like this:

The applet consists of three parts:

- a means of setting a name for the user.
- a scrolling list of messages.
- a means of sending a new message.

The first thing to do is to set a name for the user. Type the users name in the upper text field, and press Return. The text field is grayed out, and the "SignOff" button is activated.

You have now joined the chat session. You can send messages by typing them in the bottom text field and when you are ready to send them, press Return. The message will be sent to all users joined to the chat session. It will appear as the last entry in the scrolling message list.

View the Chat applet source code.

If you are viewing this page from a JavaTM enabled browser and have restarted it since you completed the JSDT setup, you can run the Chat Applet by clicking on Chat.html.

  • To run the Chat program as an application, change directories to $JSDTHOME/examples and run:
  • java examples.chat.ChatUser -width 300 -height 250 -server $SERVER -port 4461 -type socket

    Ppong

    Ppong is a two player network game, based on the classic Pong game. It looks something like this:

    Press "Start a Game" to begin. If someone else is already waiting to play, you will start playing with them right away. If there is not a partner waiting for you, go get a pal to fire up this URL or hang out and wait for a partner.

    You can also fire up another instance of your browser and play against yourself. Not as easy as you think! The game plays to 7 or until one of you presses "End Game". The paddle on the left is your paddle. To control your paddle, just move your mouse up and down the screen and it will follow.

    View the Ppong applet source code.

    If you are viewing this page from a JavaTM enabled browser and have restarted it since you completed the JSDT setup, you can run the Ppong Applet by clicking on Ppong.html.

  • To run the Ppong program as an application, change directories to $JSDTHOME/examples and run:
  • java examples.ppong.Ppong -width 600 -height 450 -server $SERVER -port 4462 -type socket
    A paper entitled "Internet Based Real-Time Multiuser Simulation: Ppong!" written by James "Bo" Begole and Clifford A. Shaffer can be downloaded from here.

    You can visit the original Ppong! web site at: http://simon.cs.vt.edu/~begolej/Ppong.html.


    Sound

    This is a very simple sound server program and corresponding receiver applet. The receiver looks something like this:

    When a sound user program (the receiver) starts up, there is a list of available tracks to select from. On selection, the artwork for that track is displayed. There are four buttons displayed (initially inactive until a selection is made):

    - Stop: used to stop the current audio file being sent.
    - Play: used to start the currently selected audio file.
    - Next: used to start playing the next selection.
    - Quit: used to terminate the sound player (applications only).

    The sound server is continuously playing the audio files to interested parties. When you press Play, you are added to that list and will receive audio packets from the server, which are sent out to the speaker.

    Pressing Stop will remove you from this list of interested parties, and hence stop you receiving further audio packets.

    The sound example uses an unreliable (UDP) channel to send out the audio data.

    View the Sound applet source code.

    If you are viewing this page from a JavaTM enabled browser and have restarted it since you completed the JSDT setup, you can run the Sound Applet by clicking on Sound.html.

  • To run the Sound program as an application, change directories to $JSDTHOME/examples and run:
  • java examples.sound.SoundUser -width 400 -height 450 -server $SERVER -port 4463 -type socket

    Stock

    The stock viewer will display multiple stock quotes simultaneously, which are being sent out by the stock server. The viewer looks something like this:

    The stock server is using the "quote.yahoo.com" web site to get quote information. The stock quotes are being continuously updated. Each quote also displays news quotes associated with that stock symbol, which are being continuously scrolled.

    The controls to the left of each stock quote news determine the direction the news scrolls, or whether it's stopped.

    Stock symbols can be added with the "Add:" textfield.
    Stock symbols can be removed with the "Remove:" textfield.

    The "Update" button will get the latest stock information, and restart the scrolling of any stock quote news. The "Quit" button terminates the stock viewer.

    A stock viewer application can be started with a -stocks command line option with a set of quotes that should be initially displayed (eg: -stocks SUNW+INTC+MSFT)

    The stock viewer applet has a similar "stocks" parameter.

    View the Stock Applet source code.

    If you are viewing this page from a JavaTM enabled browser and have restarted it since you have completed the JSDT setup, you can run the Stock Applet by clicking on Stock.html.

    To run the Stock program as an application, change directories to $JSDTHOME/examples and run:

    java examples.stock.StockUser -stocks SUNW+NSCP+IBM -server $SERVER -port 4464 -type socket

    Whiteboard

    This is a simple shared whiteboard program. It looks something like this:

    The applet consists of an upper drawing area and a lower control area.

    There are eight different brush sizes in five colors (black, red, blue, green and yellow). There are five different drawing operations:

    - clearing the drawing area.
    - drawing a dot in the current brush style and color.
    - drawing a line in the current brush style and color.
    - drawing text.
    - drawing a circle in the current brush style and color.

    When you do a drawing operation, all whiteboard users will also see the same operation in their drawing areas.

    Select a brush by clicking on the appropriate style in the control panel.

    Select a color by clicking on the color in the control panel.

    To clear the drawing area, select CLR from the control panel.

    To draw a dot, select the brush style and color you want. Then select the DOT option in the control panel. Then click at the appropriate point in the drawing area.

    To draw a line, select the brush style and color you want. Then select the LINE option in the control panel. Then click twice in the drawing area to define the lines endpoints. A line will be drawn between these two points.

    To draw text, select the TEXT in the control point. Then click in the drawing area where you want the text to appear. Then type in the text, hitting the Return key to end it.

    To draw a circle, select the brush style and color you want. Then select the CIRCLE option in the control panel. Then click twice in the drawing area to define the center of the circle and the radius. A circle will be drawn using the given center point and radius.

    View the Whiteboard Applet source code.

    If you are viewing this page from a JavaTM enabled browser and have restarted it since you have completed the JSDT setup, you can run the Whiteboard Applet by clicking on Whiteboard.html.

    To run the Whiteboard program as an application, change directories to $JSDTHOME/examples and run:

    java examples.whiteboard.WhiteBoardUser -width 600 -height 350 -server $SERVER -port 4466 -type socket


    Copyright (c) 1995-99 Sun Microsystems, Inc.
    All Rights Reserved