实现这个借口:
class Server extends Frame
        implements java.awt.event.ActionListener {
加多这个方法:
        public void actionPerformed(java.awt.event.ActionEvent event) {
            Object obj = event.getSource();
            if (obj == bt){
                 //要做的事情。
            }
        }

解决方案 »

  1.   

    有错误啊
    d:\jcreator\MyProjects\server\Server\Server.java:19: myprojects.server.Server should be declared abstract; it does not define actionPerformed(java.awt.event.ActionEvent) in myprojects.server.Server
      

  2.   

    package myprojects.server;import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;class Server extends Frame implements ActionListener {
    public Button bt;
    public TextField t1;
        public TextField t2;
        public Panel panel;
        public ServerSocket ssoc;
        public Socket soc;
        public InputStream is;
        public OutputStream os;
        public DataInputStream Dis;
        public PrintStream Dos;
    public Server() {

                 panel=new Panel();
                 this.add(panel);
                 bt=new Button("Send");
             t1=new TextField(10);
             t2=new TextField(10);
             Label l1=new Label("Send");
         Label l2=new Label("R");
         t2.setEditable(false);
         panel.add(l1);
         panel.add(t1);
         panel.add(l2);
         panel.add(t2);
         panel.add(bt);
       // bt.addActionListener(this);
         
         

    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    }
    });
    }
        public void Go(int port)
        {
         try{
          ssoc=new ServerSocket(port);
          soc=ssoc.accept();
          os=soc.getOutputStream();
          Dos=new PrintStream(os);
     
          }
          catch(Exception e)
          {System.out.print("Error");
          }
        
         }
        public void Send(String s)//发送
            {
         Dos.println(s);
        
         }
        
        
    public static  void  main(String args[]) {
    System.out.println("Starting Server...");
    Server mainFrame = new Server();
    mainFrame.setSize(400, 100);
    mainFrame.setTitle("Server");
    mainFrame.setVisible(true);
    }
    }看行不??
      

  3.   

    加多这个方法:
            public void actionPerformed(java.awt.event.ActionEvent event) {
                Object obj = event.getSource();
                if (obj == bt){
                     //要做的事情。
                }
            }
    你做了这件事情没有?
      

  4.   

    package myprojects.server;import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;class Server extends Frame implements ActionListener {
    public Button bt;
    public TextField t1;
        public TextField t2;
        public Panel panel;
        public ServerSocket ssoc;
        public Socket soc;
        public InputStream is;
        public OutputStream os;
        public DataInputStream Dis;
        public PrintStream Dos;
    public Server() {

                 panel=new Panel();
                 this.add(panel);
                 bt=new Button("Send");
             t1=new TextField(10);
             t2=new TextField(10);
             Label l1=new Label("Send");
         Label l2=new Label("R");
         t2.setEditable(false);
         panel.add(l1);
         panel.add(t1);
         panel.add(l2);
         panel.add(t2);
         panel.add(bt);
       // bt.addActionListener(this);
         
         

    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    }
    });
    }
        public void Go(int port)
        {
         try{
          ssoc=new ServerSocket(port);
          soc=ssoc.accept();
          os=soc.getOutputStream();
          Dos=new PrintStream(os);
     
          }
          catch(Exception e)
          {System.out.print("Error");
          }
        
         }
        public void Send(String s)//发送
            {
         Dos.println(s);
        
         }
        
        
    public static  void  main(String args[]) {
    System.out.println("Starting Server...");
    Server mainFrame = new Server();
    mainFrame.setSize(400, 100);
    mainFrame.setTitle("Server");
    mainFrame.setVisible(true);
    }
    public void mouseEntered(java.awt.event.MouseEvent e) {
       }   public void mouseExited(java.awt.event.MouseEvent e) {
       }   public void mousePressed(java.awt.event.MouseEvent e) {
       }   public void mouseReleased(java.awt.event.MouseEvent e) {
       }}再看
      

  5.   

    package myprojects.server;import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;public class Server extends Frame implements ActionListener {
    public Button bt;
    public TextField t1;
        public TextField t2;
        public Panel panel;
        public ServerSocket ssoc;
        public Socket soc;
        public InputStream is;
        public OutputStream os;
        public DataInputStream Dis;
        public PrintStream Dos;
    public Server() {

                 panel=new Panel();
                 this.add(panel);
                 bt=new Button("Send");
             t1=new TextField(10);
             t2=new TextField(10);
             Label l1=new Label("Send");
         Label l2=new Label("R");
         t2.setEditable(false);
         panel.add(l1);
         panel.add(t1);
         panel.add(l2);
         panel.add(t2);
         panel.add(bt);
       // bt.addActionListener(this);
         
         

    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    }
    });
    }
        public void Go(int port)
        {
         try{
          ssoc=new ServerSocket(port);
          soc=ssoc.accept();
          os=soc.getOutputStream();
          Dos=new PrintStream(os);
     
          }
          catch(Exception e)
          {System.out.print("Error");
          }
        
         }
        public void Send(String s)//发送
            {
         Dos.println(s);
        
         }
        
        
    public static  void  main(String args[]) {
    System.out.println("Starting Server...");
    Server mainFrame = new Server();
    mainFrame.setSize(400, 100);
    mainFrame.setTitle("Server");
    mainFrame.setVisible(true);
    }public void actionPerformed(ActionEvent e){
    }
    public void mouseEntered(java.awt.event.MouseEvent e) {
       }   public void mouseExited(java.awt.event.MouseEvent e) {
       }   public void mousePressed(java.awt.event.MouseEvent e) {
       }   public void mouseReleased(java.awt.event.MouseEvent e) {
       }} 
     
    搞定了我试了行的!