MudInput.java

MudInput.java · 616 B

From the archive JavaMud.tar.gz

Download the archive   « Back to the archive contents

import java.io.*;
import java.applet.*;
import java.awt.*;
import Mud;

class MudInput extends TextField
{
    Mud mud = null;
 
    public MudInput(int cols, Mud mud) {
       super(cols);
       this.mud = mud;            
    }

    public boolean handleEvent(Event e){
       if( (e.id == e.KEY_PRESS) && (e.key == '\n')){
         this.mud.connection.WriteString(this.getText() +"\n\r");
         this.mud.out.appendText(this.getText() + "\n");
         this.mud.out.appendText(this.mud.connection.ReadString() + "\n");
         this.setText(""); 
         return true;
       }
       return false;
    }



}

Site Stats

Snippets: 1791
Codebases: 571