Exemple #1
0
  public void windowClosing(WindowEvent e) {
    if (server != null) {
      try {
        server.stop();
      } catch (Exception eClose) {
      }
      server = null;
    }

    dispose();
    System.exit(0);
  }
 /*
  * If the user click the X button to close the application
  * I need to close the connection with the server to free the port
  */
 public void windowClosing(WindowEvent e) {
   // if my Server exist
   if (server != null) {
     try {
       server.stop(); // ask the server to close the conection
     } catch (Exception eClose) {
     }
     server = null;
   }
   // dispose the frame
   dispose();
   System.exit(0);
 }
  public void actionPerformed(ActionEvent e) {

    // if running we have to stop

    if (server != null) {

      server.stop();

      server = null;

      tPortNumber.setEditable(true);

      stopStart.setText("Start");

      return;
    }

    // OK start the server

    int port;

    try {

      port = Integer.parseInt(tPortNumber.getText().trim());

    } catch (Exception er) {

      appendEvent("Invalid port number");

      return;
    }

    // ceate a new Server

    server = new Server(port, this);

    // and start it as a thread

    new ServerRunning().start();

    stopStart.setText("Stop");

    tPortNumber.setEditable(false);
  }
Exemple #4
0
  public void actionPerformed(ActionEvent e) {
    if (server != null) {
      server.stop();
      server = null;
      tPortNumber.setEditable(true);
      stopStart.setText("Start");
      return;
    }

    int port;
    try {
      port = Integer.parseInt(tPortNumber.getText().trim());
    } catch (Exception er) {
      appendEvent("Invalid port number.");
      return;
    }

    server = new Server(port, this);
    new ServerRunning().start();
    stopStart.setText("Stop");
    tPortNumber.setEditable(false);
  }