Logo Search packages:      
Sourcecode: webcam-server version File versions  Download package

Frame ImageCanvas::createChat (  )  [inline]

create a simple chat window

Definition at line 243 of file ImageCanvas.java.

References ImageDownloader::queueChatText().

      {
            if(connected != CONNECTED)
                  return null;
            Frame f = new Frame("WebCam Chat");
            Panel p = new Panel();
            input = new TextField();
            output = new TextArea("please type your name in the 'name' field\n");

            p.setLayout(new BorderLayout());    

            f.setLayout(new BorderLayout());

            p.add(input, BorderLayout.CENTER);
            p.add(name, BorderLayout.WEST);
            f.add(p, BorderLayout.SOUTH);
            f.add(output, BorderLayout.CENTER);
            output.setEditable(false);

            input.addKeyListener(new KeyListener(){
                  public void keyTyped(KeyEvent e){}
                  public void keyPressed(KeyEvent e)
                  {
                        if(e.getKeyCode() == KeyEvent.VK_ENTER && !input.getText().equals(""))
                        {     
                              String message = name.getText() + ": " + input.getText() + "\n";
                              output.append(message);
                              input.setText("");
                              downloader.queueChatText(message);
                        }
                  }
                  public void keyReleased(KeyEvent e) {}
            });

            f.addWindowListener(new WindowListener()
            {
                  public void windowActivated(WindowEvent e){}
                  public void windowClosed(WindowEvent e){}
                  public void windowClosing(WindowEvent e){
                        chat.dispose();
                        chat = null;
                  }
                  public void windowDeactivated(WindowEvent e){}
                  public void windowDeiconified(WindowEvent e){}
                  public void windowIconified(WindowEvent e){}
                  public void windowOpened(WindowEvent e){}
            });

            f.setBounds(200,200,300,150);
            f.show();
            return f;
      }


Generated by  Doxygen 1.6.0   Back to index