Java Code Examples for java.awt.Frame#removeWindowListener()

The following examples show how to use java.awt.Frame#removeWindowListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Launcher.java    From osp with GNU General Public License v3.0 6 votes vote down vote up
public void windowClosing(WindowEvent e) {
  OSPLog.fine("Closing frames for node "+node); //$NON-NLS-1$
  Iterator<Frame> it = frames.iterator();
  // dispose of control frame and associated frames
  while(it.hasNext()) {
    Frame frame = it.next();
    // remove this frame closer so it only operates once
    frame.removeWindowListener(this);
    frame.dispose();
  }
  if(node!=null) {
    Thread thread = node.threads.get(runner);
    if(thread!=null) {
      thread.interrupt();
      node.threads.put(runner, null);
    }
    node.frames.removeAll(frames);
    node.launchCount = Math.max(0, --node.launchCount);
    if(node.launchPanel!=null) {
      node.launchPanel.repaint();
    }
  }
}
 
Example 2
Source File: LaunchNode.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Terminates all apps launched by this node.
 */
public void terminateAll() {
  for(Iterator<Process> it = processes.iterator(); it.hasNext(); ) {
    Process proc = it.next();
    proc.destroy();
  }
  for(Iterator<Frame> it = frames.iterator(); it.hasNext(); ) {
    Frame frame = it.next();
    WindowListener[] listeners = frame.getWindowListeners();
    for(int j = 0; j<listeners.length; j++) {
      if(listeners[j] instanceof Launcher.FrameCloser) {
        frame.removeWindowListener(listeners[j]);
      }
    }
    frame.dispose();
  }
  for(Iterator<Thread> it = threads.values().iterator(); it.hasNext(); ) {
    Thread thread = it.next();
    if(thread!=null) {
      thread.interrupt();
    }
  }
  Collection<Action> allActions = new HashSet<Action>(actions);
  for(Iterator<Action> it = allActions.iterator(); it.hasNext(); ) {
    Action action = it.next();
    if(action!=null) {
      action.actionPerformed(null);
    }
  }
  processes.clear();
  frames.clear();
  threads.clear();
  actions.clear();
  launchCount = 0;
}