/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
  private synchronized void broadcast(int i) {
    ObjectOutputStream dataOut = null;

    for (Enumeration e = clients.elements(); e.hasMoreElements(); ) {
      dataOut = (ObjectOutputStream) (e.nextElement());
      try {
        dataOut.writeInt(i);
        dataOut.flush();
      } catch (Exception x) {
        System.out.println(x.getMessage() + ": Failed to broadcast to client.");
        clients.removeElement(dataOut);
      }
    }
  }
Ejemplo n.º 3
0
 public int sendAsync(final Message query, final ResolverListener listener) {
   final int id = uniqueID(query);
   if (workerthreads == null) workerthreads = new Vector();
   WorkerThread t = null;
   synchronized (workerthreads) {
     if (workerthreads.size() > 0) {
       t = (WorkerThread) workerthreads.firstElement();
       workerthreads.removeElement(t);
     }
   }
   if (t == null) {
     t = new WorkerThread(this, workerthreads);
     t.setDaemon(true);
     t.start();
   }
   synchronized (t) {
     t.assign(query, id, listener);
     t.notify();
   }
   return id;
 }
Ejemplo n.º 4
0
 /**
  * Remove a Connection event listener.
  *
  * <p>The default implementation provided here removes this listener from the internal list of
  * ConnectionListeners.
  *
  * @param l the listener
  * @see #addConnectionListener
  */
 public void removeConnectionListener(ConnectionListener l) {
   connectionListeners.removeElement(l);
 }
Ejemplo n.º 5
0
 public void removeConnection(connection c) {
   connections.removeElement(c);
   sendGlobalServerMsg("Benutzer " + c.getNickname() + " hat den Server verlassen");
 }