本文整理了Java中java.awt.Container.isAncestorOf()
方法的一些代码示例,展示了Container.isAncestorOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Container.isAncestorOf()
方法的具体详情如下:
包路径:java.awt.Container
类名称:Container
方法名:isAncestorOf
[英]Checks if the component is contained in the component hierarchy of this container.
[中]
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
protected boolean isKnownComponent(Component c) {
if (c == null) return false;
if (c == this) return true;
if (c == editorComp) return true;
if (c == searchField) return true;
if (c == this.getRootPane()) return true;
if (c instanceof Container && ((Container) c).isAncestorOf(this)) {
return true;
}
if ((editorComp instanceof Container) && ((Container) editorComp).isAncestorOf(c)) return true;
return false;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
protected boolean isKnownComponent(Component c) {
if (c == null) return false;
if (c == this) return true;
if (c == editorComp) return true;
if (c == searchField) return true;
if (c == this.getRootPane()) return true;
if (c instanceof Container && ((Container) c).isAncestorOf(this)) {
return true;
}
if ((editorComp instanceof Container) && ((Container) editorComp).isAncestorOf(c)) return true;
return false;
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
protected boolean isKnownComponent(Component c) {
if (c == null) {
return false;
}
if (c == this) {
return true;
}
if (c == editorComp) {
return true;
}
if (c == searchField) {
return true;
}
if (c == this.getRootPane()) {
return true;
}
if (c instanceof Container && ((Container) c).isAncestorOf(this)) {
return true;
}
if ((editorComp instanceof Container) && ((Container) editorComp).isAncestorOf(c)) {
return true;
}
return false;
}
代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking
/** Returns a list of all dockables contained into base
*/
private ArrayList findDockables(Container base) {
ArrayList dockables = new ArrayList(10);
Iterator<Dockable> it = constraintsByDockable.keySet().iterator();
while(it.hasNext()) {
Dockable d = it.next();
if(base.isAncestorOf(d.getComponent())) {
dockables.add(d);
}
}
return dockables;
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
boolean isKnownComponent(Component c) {
if (c == null) {
return false;
}
if (isAncestorOf(c)) {
return true;
}
if (c == editorComp) {
return true;
}
if ((editorComp != null) && (editorComp instanceof Container) && ((Container) editorComp).isAncestorOf(c)) {
return true;
}
return false;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
boolean isKnownComponent (Component c) {
if (c == null) return false;
if (isAncestorOf (c)) {
return true;
}
if (c == editorComp) {
return true;
}
if (editorComp != null && (editorComp instanceof Container) &&
((Container) editorComp).isAncestorOf(c)) {
return true;
}
return false;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
boolean isKnownComponent (Component c) {
if (c == null) return false;
if (isAncestorOf (c)) {
return true;
}
if (c == editorComp) {
return true;
}
if (editorComp != null && (editorComp instanceof Container) &&
((Container) editorComp).isAncestorOf(c)) {
return true;
}
return false;
}
代码示例来源:origin: in.jlibs/org-netbeans-swing-outline
/**
* Checks whether the given component is "our".
*/
private boolean isKnownComponent(Component c) {
if (c == null) return false;
if (isAncestorOf (c)) {
return true;
}
if (c == editorComp) {
return true;
}
if (editorComp != null && (editorComp instanceof Container) &&
((Container) editorComp).isAncestorOf(c)) {
return true;
}
return false;
}
代码示例来源:origin: com.jidesoft/jide-oss
public static boolean isAncestorOfFocusOwner(Component component) {
boolean hasFocus = false;
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (component == focusOwner || (component instanceof Container && ((Container) component).isAncestorOf(focusOwner))) {
hasFocus = true;
}
return hasFocus;
}
代码示例来源:origin: com.jidesoft/jide-oss
public void focusLost(FocusEvent e) {
Container topLevelAncestor = _popup.getTopLevelAncestor();
if (topLevelAncestor == null) {
return;
}
Component oppositeComponent = e.getOppositeComponent();
if (topLevelAncestor == oppositeComponent || topLevelAncestor.isAncestorOf(oppositeComponent)) {
return;
}
hideHintsPopup();
}
});
代码示例来源:origin: com.jidesoft/jide-oss
@Override
public Component getLastComponent(Container aContainer) {
if (_defaultPolicy == null) {
return null;
}
Component component = _defaultPolicy.getLastComponent(aContainer);
Component aComponent = component;
boolean componentChanged;
do {
componentChanged = false;
for (Container container : _containers) {
if (container.isAncestorOf(component)) {
Rectangle collapsiblePaneBounds = container.getBounds();
Container parent = container.getParent();
Rectangle bounds = SwingUtilities.convertRectangle(component.getParent(), component.getBounds(), parent);
if (bounds.x < collapsiblePaneBounds.x + collapsiblePaneBounds.width && bounds.x + bounds.width > collapsiblePaneBounds.x && bounds.y < collapsiblePaneBounds.y + collapsiblePaneBounds.height && bounds.y + bounds.height > collapsiblePaneBounds.y) {
return component;
}
component = _defaultPolicy.getComponentBefore(aContainer, component);
componentChanged = true;
break;
}
}
}
while (component != null && aComponent != component && componentChanged);
return component;
}
代码示例来源:origin: com.jidesoft/jide-oss
@Override
public Component getComponentBefore(Container aContainer, Component aComponent) {
if (_defaultPolicy == null) {
return null;
}
Component component = _defaultPolicy.getComponentBefore(aContainer, aComponent);
boolean componentChanged = true;
while (component != null && aComponent != component && componentChanged) {
componentChanged = false;
for (Container container : _containers) {
if (container.isAncestorOf(component)) {
Rectangle collapsiblePaneBounds = container.getBounds();
Container parent = container.getParent();
Rectangle bounds = SwingUtilities.convertRectangle(component.getParent(), component.getBounds(), parent);
if (bounds.x < collapsiblePaneBounds.x + collapsiblePaneBounds.width && bounds.x + bounds.width > collapsiblePaneBounds.x && bounds.y < collapsiblePaneBounds.y + collapsiblePaneBounds.height && bounds.y + bounds.height > collapsiblePaneBounds.y) {
return component;
}
component = _defaultPolicy.getComponentBefore(aContainer, component);
componentChanged = true;
break;
}
}
}
return component;
}
代码示例来源:origin: com.jidesoft/jide-oss
/**
* Checks if a component is an excluded component. If a component is an excluded component, clicking on it will not
* hide the popup. By default, owner is always the excluded component.
*
* @param component a component.
* @return true if the component is an excluded component.
*/
public boolean isExcludedComponent(Component component) {
boolean contain = _excludedComponents.contains(component);
if (!contain) {
for (Component c : _excludedComponents) {
if (c instanceof Container) {
if (((Container) c).isAncestorOf(component)) {
return true;
}
}
}
if (component instanceof JComponent) {
Container c = ((JComponent) component).getTopLevelAncestor();
if (c instanceof RootPaneContainer) {
JComponent realParent = getRealParent((RootPaneContainer) c);
if (realParent != null && realParent.getTopLevelAncestor() == getTopLevelAncestor()) {
return true;
}
}
}
}
return contain;
}
代码示例来源:origin: com.jidesoft/jide-oss
@Override
public Component getComponentAfter(Container aContainer, Component aComponent) {
if (_defaultPolicy == null) {
return null;
}
Component component = _defaultPolicy.getComponentAfter(aContainer, aComponent);
boolean componentChanged = true;
while (component != null && aComponent != component && componentChanged) {
componentChanged = false;
for (Container container : _containers) {
if (container.isAncestorOf(component)) {
Rectangle collapsiblePaneBounds = container.getBounds();
Container parent = container.getParent();
Rectangle bounds = SwingUtilities.convertRectangle(component.getParent(), component.getBounds(), parent);
if (bounds.x < collapsiblePaneBounds.x + collapsiblePaneBounds.width && bounds.x + bounds.width > collapsiblePaneBounds.x && bounds.y < collapsiblePaneBounds.y + collapsiblePaneBounds.height && bounds.y + bounds.height > collapsiblePaneBounds.y) {
return component;
}
component = _defaultPolicy.getComponentAfter(aContainer, component);
componentChanged = true;
break;
}
}
}
return component;
}
代码示例来源:origin: com.jidesoft/jide-oss
@Override
public Component getFirstComponent(Container aContainer) {
if (_defaultPolicy == null) {
return null;
}
Component component = _defaultPolicy.getFirstComponent(aContainer);
Component aComponent = component;
boolean componentChanged;
do {
componentChanged = false;
for (Container container : _containers) {
if (container.isAncestorOf(component)) {
Rectangle collapsiblePaneBounds = container.getBounds();
Container parent = container.getParent();
Rectangle bounds = SwingUtilities.convertRectangle(component.getParent(), component.getBounds(), parent);
if (bounds.x < collapsiblePaneBounds.x + collapsiblePaneBounds.width && bounds.x + bounds.width > collapsiblePaneBounds.x && bounds.y < collapsiblePaneBounds.y + collapsiblePaneBounds.height && bounds.y + bounds.height > collapsiblePaneBounds.y) {
return component;
}
component = _defaultPolicy.getComponentAfter(aContainer, component);
componentChanged = true;
break;
}
}
}
while (component != null && aComponent != component && componentChanged);
return component;
}
代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking
/** {@inheritDoc} */
public boolean startDragComponent(Point p) {
// disable DnD for some cases :
// - child of a compound dockable, in hidden state
// - child of a maximized compund dockable
// - maximized dockable
DockableState.Location targetLocation = target.getDockKey().getLocation();
if(targetLocation == DockableState.Location.HIDDEN) {
if(DockingUtilities.isChildOfCompoundDockable(target)) {
// nested hidden dockables cannot be drag and dropped
return false;
}
} else if(targetLocation == DockableState.Location.DOCKED) {
boolean isChildOfMaximizedContainer = false;
if(desktop != null) {
Dockable max = desktop.getMaximizedDockable();
if(max != null && max.getComponent().getParent().isAncestorOf(this)) {
isChildOfMaximizedContainer = true;
}
}
if(isChildOfMaximizedContainer) {
return false;
}
} else if(targetLocation == DockableState.Location.MAXIMIZED) {
return false;
}
// notify our listeners that drag has begun
firePropertyChange(PROPERTY_DRAGGED, false, true);
return true;
}
代码示例来源:origin: com.jidesoft/jide-oss
/**
* This method will process component event. By default, if popup's ancestor is hidden, we will hide the popup as
* well if the popup is transient (isTransient returns true). If popup's ancestor is moved, we will either move or
* hide the popup depending on {@link #getDefaultMoveOperation()} value.
*
* @param e the ComponentEvent.
*/
protected void handleComponentEvent(ComponentEvent e) {
Component owner = getActualOwner();
if (!(e.getSource() instanceof Container)) {
return;
}
Container container = (Container) e.getSource();
if (e.getID() == ComponentEvent.COMPONENT_HIDDEN && (container == owner || container.isAncestorOf(owner))) {
ancestorHidden();
}
else if (e.getID() == ComponentEvent.COMPONENT_MOVED && (container == owner || container.isAncestorOf(owner))) {
// this line is for Linux because the JFrame moves when combobox is shown inside JidePopup
// System.out.println("_actualOwnerLocation " + _actualOwnerLocation + " _actualOwner " + _actualOwner + " _actualOwner.getLocationOnScreen() " + (_actualOwner != null ? _actualOwner.getLocationOnScreen() : null));
try {
if (_actualOwnerLocation == null || _actualOwner == null || !_actualOwner.getLocationOnScreen().equals(_actualOwnerLocation)) {
ancestorMoved();
}
}
catch (Exception ex) {
// ignore in case IllegalComponentStateException happens in getLocationOnScreen
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
if ((getParent() != null) && (getParent().isAncestorOf (c))) return true;
if (par != null && par.isAncestorOf(c)) return true;
if (c instanceof InplaceEditor) return true;
InplaceEditor ine = getEditor().getInplaceEditor();
代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking
private void scanContainer(DockEvent event, boolean drop) {
if(event.getDragSource().getDockableContainer().isAncestorOf(this)) {
代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking
private void scanContainer(DockEvent event, boolean drop) {
// reject operation if the source is an ancestor of this component
if(event.getDragSource().getDockableContainer().isAncestorOf(this)) {
// this is possible for compound containers (as they contain sub-dockables)
// in that case, you cannnot drop a compound into one of its children // 2007/01/08
if(drop) {
((DockDropEvent) event).rejectDrop();
} else {
((DockDragEvent) event).delegateDrag();
}
return;
}
@SuppressWarnings("unused")
Point p = event.getMouseEvent().getPoint();
Rectangle compBounds = getBounds();
Dockable dragged = event.getDragSource().getDockable();
DockableState.Location initialLocation = dragged.getDockKey().getLocation();
DockableState.Location nextLocation = dockable.getDockKey().getLocation();
event.setDockingAction(new DockingActionAddDockableEvent(event.getDesktop(), dragged, initialLocation, nextLocation, this));
if(drop) {
acceptDrop(event);
} else {
Rectangle2D r2d = new Rectangle2D.Float(0, 0, compBounds.width, compBounds.height);
((DockDragEvent) event).acceptDrag(r2d);
}
}
内容来源于网络,如有侵权,请联系作者删除!