本文整理汇总了Java中java.awt.Container.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Container.getX方法的具体用法?Java Container.getX怎么用?Java Container.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Container
的用法示例。
在下文中一共展示了Container.getX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canDirectlyAccessGraphics
import java.awt.Container; //导入方法依赖的package包/类
protected boolean canDirectlyAccessGraphics() {
// TODO: what about popup windows / tooltips???
// TODO: some of the queries could be cached instead of polling,
// for example isShowing(), isOpaque(), getParent() etc.
////// // Shouldn't access graphics - no buffering would cause flickering
////// if (bufferType == BUFFER_NONE) return false;
// Cannot access graphics - there are some child components
if (getComponentCount() != 0) return false;
// Cannot access graphics - component doesn't fully control its area
if (!isOpaque()) return false;
// Cannot access graphics - not in Swing tree
if (!(getParent() instanceof JComponent)) return false;
// Cannot access graphics - component not showing, doesn't make sense
if (!isShowing()) return false;
// Cannot access graphics - component area is not up-to-date
Rectangle dirtyRegion = RepaintManager.currentManager(this).
getDirtyRegion((JComponent)getParent());
if (dirtyRegion != null && dirtyRegion.width > 0 &&
dirtyRegion.height > 0) return false;
// --- Reused from JViewport -------------------------------------------
Rectangle clip = new Rectangle(0, 0, getWidth(), getHeight());
Rectangle oldClip = new Rectangle();
Rectangle tmp2 = null;
Container parent;
Component lastParent = null;
int x, y, w, h;
for (parent = this; parent != null && isLightweightComponent(parent); parent = parent.getParent()) {
x = parent.getX();
y = parent.getY();
w = parent.getWidth();
h = parent.getHeight();
oldClip.setBounds(clip);
SwingUtilities.computeIntersection(0, 0, w, h, clip);
if (!clip.equals(oldClip)) return false;
if (lastParent != null && parent instanceof JComponent &&
!((JComponent)parent).isOptimizedDrawingEnabled()) {
Component comps[] = parent.getComponents();
int index = 0;
for (int i = comps.length - 1 ;i >= 0; i--) {
if (comps[i] == lastParent) {
index = i - 1;
break;
}
}
while (index >= 0) {
tmp2 = comps[index].getBounds(tmp2);
if (tmp2.intersects(clip)) return false;
index--;
}
}
clip.x += x;
clip.y += y;
lastParent = parent;
}
// No Window parent.
if (parent == null) return false;
return true;
}