com.objogate.wl.swing.probe.TopLevelWindowFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of windowlicker-swing Show documentation
Show all versions of windowlicker-swing Show documentation
This is the Windowlicker Swing library.
The newest version!
package com.objogate.wl.swing.probe;
import java.awt.Frame;
import java.awt.Window;
import java.util.*;
import org.hamcrest.Description;
import com.objogate.wl.swing.ComponentFinder;
public class TopLevelWindowFinder implements ComponentFinder {
private List found = Collections.emptyList();
public boolean isSatisfied() {
return true;
}
public List components() {
return found;
}
public void probe() {
Set topLevelWindows = new HashSet();
for (Frame frame : Frame.getFrames()) {
topLevelWindows.add(ownershipRoot(frame));
}
found = new ArrayList(topLevelWindows);
}
private static Window ownershipRoot(Window w) {
return w.getOwner() == null
? w
: ownershipRoot(w.getOwner());
}
public void describeTo(Description description) {
description.appendText("all top level windows");
}
public void describeFailureTo(Description description) {
describeTo(description);
}
}