提交 a0158dbd 编写于 作者: D dav

Merge

......@@ -2141,7 +2141,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
Toolkit.getEventQueue().postEvent(e);
}
} else {
if (this instanceof Container && ((Container)this).ncomponents > 0) {
if (this instanceof Container && ((Container)this).countComponents() > 0) {
boolean enabledOnToolkit =
Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
if (resized) {
......
......@@ -357,7 +357,7 @@ public class ScrollPane extends Container implements Accessible {
*/
public void setScrollPosition(int x, int y) {
synchronized (getTreeLock()) {
if (ncomponents <= 0) {
if (getComponentCount()==0) {
throw new NullPointerException("child is null");
}
hAdjustable.setValue(x);
......@@ -393,11 +393,13 @@ public class ScrollPane extends Container implements Accessible {
*/
@Transient
public Point getScrollPosition() {
if (ncomponents <= 0) {
synchronized (getTreeLock()) {
if (getComponentCount()==0) {
throw new NullPointerException("child is null");
}
return new Point(hAdjustable.getValue(), vAdjustable.getValue());
}
}
/**
* Sets the layout manager for this container. This method is
......@@ -486,7 +488,9 @@ public class ScrollPane extends Container implements Accessible {
*/
@Deprecated
public void layout() {
if (ncomponents > 0) {
if (getComponentCount()==0) {
return;
}
Component c = getComponent(0);
Point p = getScrollPosition();
Dimension cs = calculateChildSize();
......@@ -506,7 +510,6 @@ public class ScrollPane extends Container implements Accessible {
hAdjustable.setSpan(0, cs.width, vs.width);
vAdjustable.setSpan(0, cs.height, vs.height);
}
}
/**
* Prints the component in this scroll pane.
......@@ -515,8 +518,10 @@ public class ScrollPane extends Container implements Accessible {
* @see Component#printAll
*/
public void printComponents(Graphics g) {
if (ncomponents > 0) {
Component c = component[0];
if (getComponentCount()==0) {
return;
}
Component c = getComponent(0);
Point p = c.getLocation();
Dimension vs = getViewportSize();
Insets i = getInsets();
......@@ -530,7 +535,6 @@ public class ScrollPane extends Container implements Accessible {
cg.dispose();
}
}
}
/**
* Creates the scroll pane's peer.
......@@ -589,7 +593,7 @@ public class ScrollPane extends Container implements Accessible {
default:
sdpStr = "invalid display policy";
}
Point p = ncomponents > 0? getScrollPosition() : new Point(0,0);
Point p = (getComponentCount()>0)? getScrollPosition() : new Point(0,0);
Insets i = getInsets();
return super.paramString()+",ScrollPosition=("+p.x+","+p.y+")"+
",Insets=("+i.top+","+i.left+","+i.bottom+","+i.right+")"+
......
/*
* Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -30,8 +30,6 @@
* AwtContainer fields
*/
jfieldID AwtContainer::ncomponentsID;
jfieldID AwtContainer::componentID;
jfieldID AwtContainer::layoutMgrID;
jmethodID AwtContainer::findComponentAtMID;
......@@ -45,18 +43,12 @@ JNIEXPORT void JNICALL
Java_java_awt_Container_initIDs(JNIEnv *env, jclass cls) {
TRY;
AwtContainer::ncomponentsID = env->GetFieldID(cls, "ncomponents", "I");
AwtContainer::componentID =
env->GetFieldID(cls, "component", "[Ljava/awt/Component;");
AwtContainer::layoutMgrID =
env->GetFieldID(cls, "layoutMgr", "Ljava/awt/LayoutManager;");
AwtContainer::findComponentAtMID =
env->GetMethodID(cls, "findComponentAt", "(IIZ)Ljava/awt/Component;");
DASSERT(AwtContainer::ncomponentsID != NULL);
DASSERT(AwtContainer::componentID != NULL);
DASSERT(AwtContainer::layoutMgrID != NULL);
DASSERT(AwtContainer::findComponentAtMID);
......
/*
* Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -37,8 +37,6 @@ class AwtContainer {
public:
/* java.awt.Container field ids */
static jfieldID ncomponentsID;
static jfieldID componentID;
static jfieldID layoutMgrID;
static jmethodID findComponentAtMID;
......
/*
@test %I% %E%
@bug 2161766
@summary Component is missing after changing the z-order of the component & focus is not transfered in
@author Andrei Dmitriev : area=awt.container
@run main CheckZOrderChange
*/
import java.awt.*;
import java.awt.event.*;
public class CheckZOrderChange {
private static Button content[] = new Button[]{new Button("Button 1"), new Button("Button 2"), new Button("Button 3"), new Button("Button 4")};
private static Frame frame;
public static void main(String[] args) {
frame = new Frame("Test Frame");
frame.setLayout(new FlowLayout());
for (Button b: content){
frame.add(b);
}
frame.setSize(300, 300);
frame.setVisible(true);
/* INITIAL ZORDERS ARE*/
for (Button b: content){
System.out.println("frame.getComponentZOrder("+ b +") = " + frame.getComponentZOrder(b));
}
//Change the Z Order
frame.setComponentZOrder(content[0], 2);
System.out.println("ZOrder of button1 changed to 2");
if (frame.getComponentZOrder(content[0]) != 2 ||
frame.getComponentZOrder(content[1]) != 0 ||
frame.getComponentZOrder(content[2]) != 1 ||
frame.getComponentZOrder(content[3]) != 3)
{
for (Button b: content){
System.out.println("frame.getComponentZOrder("+ b +") = " + frame.getComponentZOrder(b));
}
throw new RuntimeException("TEST FAILED: getComponentZOrder did not return the correct value");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册