本文整理汇总了Java中java.awt.Container.isAncestorOf方法的典型用法代码示例。如果您正苦于以下问题:Java Container.isAncestorOf方法的具体用法?Java Container.isAncestorOf怎么用?Java Container.isAncestorOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Container
的用法示例。
在下文中一共展示了Container.isAncestorOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForComponentOrChildToGetFocus
import java.awt.Container; //导入方法依赖的package包/类
public static Component waitForComponentOrChildToGetFocus(Container c) {
Component foc = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
int ct=0;
while (foc == null || (foc != c && !c.isAncestorOf(foc))) {
try {
Thread.currentThread().sleep(100);
} catch (Exception e ) {}
foc = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
ct++;
if (ct > 200) {
break;
}
}
return foc;
}
示例2: reset
import java.awt.Container; //导入方法依赖的package包/类
/** Resets panel back after monitoring search. Implements <code>ProgressMonitor</code> interface method. */
public void reset() {
Container container = (Container) getComponent();
if(!container.isAncestorOf(getUI())) {
container.removeAll();
GridBagConstraints constraints = new GridBagConstraints();
constraints.weightx = 1.0;
constraints.weighty = 1.0;
constraints.fill = GridBagConstraints.BOTH;
container.add(getUI(), constraints);
}
}
示例3: isKnownComponent
import java.awt.Container; //导入方法依赖的package包/类
/** See if a component is one we know about or one the current editor
* knows about. This affects whether we paint as if focused or not, and
* is used to determine what kind of focus changes mean we should stop
* editing, and what kind are ok */
@Override
protected boolean isKnownComponent(Component c) {
boolean result = super.isKnownComponent(c);
if (result) {
return result;
}
if (c == null) {
return false;
}
if (c instanceof ButtonPanel) {
return true;
}
InplaceEditor ie = getEditor().getInplaceEditor();
if (ie != null) {
JComponent comp = ie.getComponent();
if (comp == c) {
return true;
}
if (comp.isAncestorOf(c)) {
return true;
}
}
if (c.getParent() instanceof ButtonPanel) {
return true;
}
if ((getParent() != null) && (getParent().isAncestorOf(c))) {
return true;
}
Container par = getParent();
if ((par != null) && par.isAncestorOf(c)) {
return true;
}
if (c instanceof InplaceEditor) {
return true;
}
InplaceEditor ine = getEditor().getInplaceEditor();
if (ine != null) {
return ine.isKnownComponent(c);
}
return false;
}
示例4: checkFocusedContainer
import java.awt.Container; //导入方法依赖的package包/类
/** Determine if a container or its child has focus. If it is a window,
* it must be the focused window */
protected static boolean checkFocusedContainer(Container c) throws Exception {
synchronized (c.getTreeLock()) {
c.getTreeLock().notifyAll();
}
if (SwingUtilities.isEventDispatchThread()) {
//If the hide action is pending, allow it to happen before
//checking if something happened
drainEventQueue();
} else {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
try {
drainEventQueue();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
}
Toolkit.getDefaultToolkit().sync();
//Here we're waiting for the native window system to do *its* focus
//transferring. So do some extra waiting - otherwise sometimes focus
//hasn't arrived at the frame and the events handled by AWT
sleep();
sleep();
sleep();
sleep();
sleep();
Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
Component currowner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
Component permowner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
if (w == null) {
return false;
}
if (w.isAncestorOf(currowner)) {
//believe it or not this happens
if (c instanceof Window && w != c) {
System.err.println("Focused window is " + w);
return false;
}
}
if (c.isAncestorOf(currowner)) {
return true;
}
if (c.isAncestorOf(permowner)) {
return true;
}
return false;
}