TransJam Collaboration Server

TransJam Client Programming Tutorial

Home Documentation Chat Demo WebDrum

Adding a ChatPanel

Any application that uses the Transjam server can also provide a chat window.  So we have provided a simple ChatPanel that supports basic chat operations. Simply add the ChatPanel to your Applet. Then tell the ChatPanel to start(). This tells the ChatPanel to listen for messages from the server and to respond appropriately.

We then ask the ClientHelper to login(). This puts up a dialog asking the user for their name. The start() method can then return. The user will not actually be logged in until they finish the dialog.

        // Create a panel for chatting with others.
            setLayout( new BorderLayout() );
            add( "Center", chatPanel = new ChatPanel( client, 10, 70, true ) );
            chatPanel.start();

        // Login to the server using a popup Dialog.
            helper.login();
        }
    // Make the GUI visible.
        getParent().validate();
        getToolkit().sync();
    }
Note the odd code at the end. This is needed because some browsers do not display the components of an Applet until you validate the parent and flush all the graphics commands. If the AWT components in your Applet don't show up until you resize the window, then try this little trick.

[Previous] [Top] [Next]

(C) 2002 SoftSynth.com