下面列出了java.awt.Window#getOwnedWindows ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void testDialog_Multiple_Match() throws Exception {
positionListingTop(0x40D3B8);
DropDownSelectionTextField<?> textField = showTypeChooserDialog();
triggerText(textField, "undefined");
DialogComponentProvider dialog = getDialog();
JComponent component = dialog.getComponent();
Window dataTypeDialog = windowForComponent(component);
Window[] popUpWindows = dataTypeDialog.getOwnedWindows();
List<Component> dataTypeWindows = new ArrayList<>(Arrays.asList(popUpWindows));
dataTypeWindows.add(dataTypeDialog);
captureComponents(dataTypeWindows);
closeAllWindowsAndFrames();
}
@Test
public void testDialog_Single_Match() throws Exception {
positionListingTop(0x40D3B8);
DropDownSelectionTextField<?> textField = showTypeChooserDialog();
triggerText(textField, "qword");
DialogComponentProvider dialog = getDialog();
JComponent component = dialog.getComponent();
Window dataTypeDialog = windowForComponent(component);
Window[] popUpWindows = dataTypeDialog.getOwnedWindows();
List<Component> dataTypeWindows = new ArrayList<>(Arrays.asList(popUpWindows));
dataTypeWindows.add(dataTypeDialog);
captureComponents(dataTypeWindows);
}
public WindowNode(Window win) {
super(win);
Window[] wns = win.getOwnedWindows();
Vector<WindowNode> wwns = new Vector<>();
for (Window wn : wns) {
if (propDialog.showAll || wn.isVisible()) {
wwns.add(new WindowNode(wn));
}
}
wins = new WindowNode[wwns.size()];
for (int i = 0; i < wwns.size(); i++) {
wins[i] = wwns.get(i);
}
title = win.toString();
clss = win.getClass().getName();
BufferedImage image = null;
try {
image = new Robot().
createScreenCapture(new Rectangle(win.getLocationOnScreen(),
win.getSize()));
} catch (AWTException e) {
e.printStackTrace();
}
setComponentImageProvider(new ComponentImageProvider(image, x, y));
}
private static Window getAWindow(Window owner, ComponentChooser cc) {
if (owner == null) {
return WindowWaiter.getAWindow(cc);
} else {
Window result = null;
Window[] windows = owner.getOwnedWindows();
for (Window window : windows) {
if (cc.checkComponent(window)) {
return window;
}
if ((result = WindowWaiter.getWindow(window, cc)) != null) {
return result;
}
}
return null;
}
}
private static boolean isHierarchyShowing(Window w) {
if (w.isShowing()) {
return true;
}
Window[] children = w.getOwnedWindows();
for (Window child : children) {
if (child.isShowing()) {
return true;
}
}
return false;
}
private static void windowToString(Window w, int depth, StringBuilder buffy) {
String title = getDebugTitleForWindow(w);
String prefix = StringUtils.repeat('\t', depth);
String visibility = w.isShowing() ? "" : " (not showing)";
String padded = prefix + title + visibility;
buffy.append(padded).append('\n');
Window[] children = w.getOwnedWindows();
for (Window child : children) {
windowToString(child, depth + 1, buffy);
}
}
private static boolean hasModalDialog(Window w) {
if (w == null) { // #63830
return false;
}
Window[] ws = w.getOwnedWindows();
for(int i = 0; i < ws.length; i++) {
if(ws[i] instanceof Dialog && ((Dialog)ws[i]).isModal() && ws[i].isVisible()) {
return true;
} else if(hasModalDialog(ws[i])) {
return true;
}
}
return false;
}
/**
* Updates the UI of the passed in window and all its children.
*/
private static void updateWindowUI(Window window) {
SwingUtilities.updateComponentTreeUI(window);
Window[] ownedWins = window.getOwnedWindows();
for (Window ownedWin : ownedWins) {
updateWindowUI(ownedWin);
}
}
private static void updateWindowTreeUI(Window window) {
SwingUtilities.updateComponentTreeUI(window);
Window[] arrwindow = window.getOwnedWindows();
int n = arrwindow.length;
while (--n >= 0) {
Window window2 = arrwindow[n];
if (!window2.isDisplayable()) continue;
Test4319113.updateWindowTreeUI(window2);
}
}
/**
* @param window The window to check.
* @return {@code true} if an owned window is showing.
*/
public static boolean hasOwnedWindowsShowing(Window window) {
if (window != null) {
for (Window one : window.getOwnedWindows()) {
if (one.isShowing() && one.getType() != Window.Type.POPUP) {
return true;
}
}
}
return false;
}
private Window getTopWindow(Window in) {
for (Window window : in.getOwnedWindows()) {
if (window.isVisible()) {
return getTopWindow(window);
}
}
return in;
}