Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a0158dbd
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a0158dbd
编写于
6月 18, 2008
作者:
D
dav
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
15cd2c3b
6ea83095
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
276 addition
and
262 deletion
+276
-262
src/share/classes/java/awt/Component.java
src/share/classes/java/awt/Component.java
+1
-1
src/share/classes/java/awt/Container.java
src/share/classes/java/awt/Container.java
+184
-212
src/share/classes/java/awt/ScrollPane.java
src/share/classes/java/awt/ScrollPane.java
+41
-37
src/windows/native/sun/windows/awt_Container.cpp
src/windows/native/sun/windows/awt_Container.cpp
+1
-9
src/windows/native/sun/windows/awt_Container.h
src/windows/native/sun/windows/awt_Container.h
+1
-3
test/java/awt/Container/CheckZOrderChange/CheckZOrderChange.java
...va/awt/Container/CheckZOrderChange/CheckZOrderChange.java
+48
-0
未找到文件。
src/share/classes/java/awt/Component.java
浏览文件 @
a0158dbd
...
@@ -2141,7 +2141,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
...
@@ -2141,7 +2141,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
Toolkit
.
getEventQueue
().
postEvent
(
e
);
Toolkit
.
getEventQueue
().
postEvent
(
e
);
}
}
}
else
{
}
else
{
if
(
this
instanceof
Container
&&
((
Container
)
this
).
ncomponents
>
0
)
{
if
(
this
instanceof
Container
&&
((
Container
)
this
).
countComponents
()
>
0
)
{
boolean
enabledOnToolkit
=
boolean
enabledOnToolkit
=
Toolkit
.
enabledOnToolkit
(
AWTEvent
.
HIERARCHY_BOUNDS_EVENT_MASK
);
Toolkit
.
enabledOnToolkit
(
AWTEvent
.
HIERARCHY_BOUNDS_EVENT_MASK
);
if
(
resized
)
{
if
(
resized
)
{
...
...
src/share/classes/java/awt/Container.java
浏览文件 @
a0158dbd
/*
/*
* Copyright 1995-200
7
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1995-200
8
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -44,8 +44,6 @@ import java.io.PrintWriter;
...
@@ -44,8 +44,6 @@ import java.io.PrintWriter;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.EventListener
;
import
java.util.EventListener
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.logging.*
;
import
java.util.logging.*
;
...
@@ -90,21 +88,14 @@ public class Container extends Component {
...
@@ -90,21 +88,14 @@ public class Container extends Component {
private
static
final
Logger
log
=
Logger
.
getLogger
(
"java.awt.Container"
);
private
static
final
Logger
log
=
Logger
.
getLogger
(
"java.awt.Container"
);
private
static
final
Logger
eventLog
=
Logger
.
getLogger
(
"java.awt.event.Container"
);
private
static
final
Logger
eventLog
=
Logger
.
getLogger
(
"java.awt.event.Container"
);
/**
private
static
final
Component
[]
EMPTY_ARRAY
=
new
Component
[
0
];
* The number of components in this container.
* This value can be null.
* @see #getComponent
* @see #getComponents
* @see #getComponentCount
*/
int
ncomponents
;
/**
/**
* The components in this container.
* The components in this container.
* @see #add
* @see #add
* @see #getComponents
* @see #getComponents
*/
*/
Component
component
[]
=
new
Component
[
0
]
;
private
java
.
util
.
List
<
Component
>
component
=
new
java
.
util
.
ArrayList
<
Component
>()
;
/**
/**
* Layout manager for this container.
* Layout manager for this container.
...
@@ -290,7 +281,9 @@ public class Container extends Component {
...
@@ -290,7 +281,9 @@ public class Container extends Component {
*/
*/
@Deprecated
@Deprecated
public
int
countComponents
()
{
public
int
countComponents
()
{
return
ncomponents
;
synchronized
(
getTreeLock
())
{
return
component
.
size
();
}
}
}
/**
/**
...
@@ -302,10 +295,10 @@ public class Container extends Component {
...
@@ -302,10 +295,10 @@ public class Container extends Component {
*/
*/
public
Component
getComponent
(
int
n
)
{
public
Component
getComponent
(
int
n
)
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
if
((
n
<
0
)
||
(
n
>=
ncomponents
))
{
if
((
n
<
0
)
||
(
n
>=
component
.
size
()
))
{
throw
new
ArrayIndexOutOfBoundsException
(
"No such child: "
+
n
);
throw
new
ArrayIndexOutOfBoundsException
(
"No such child: "
+
n
);
}
}
return
component
[
n
]
;
return
component
.
get
(
n
)
;
}
}
}
}
...
@@ -322,7 +315,7 @@ public class Container extends Component {
...
@@ -322,7 +315,7 @@ public class Container extends Component {
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
final
Component
[]
getComponents_NoClientCode
()
{
final
Component
[]
getComponents_NoClientCode
()
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
return
Arrays
.
copyOf
(
component
,
ncomponents
);
return
component
.
toArray
(
EMPTY_ARRAY
);
}
}
}
// getComponents_NoClientCode()
}
// getComponents_NoClientCode()
...
@@ -421,6 +414,29 @@ public class Container extends Component {
...
@@ -421,6 +414,29 @@ public class Container extends Component {
return
comp
;
return
comp
;
}
}
/**
* Checks that the component
* isn't supposed to be added into itself.
*/
private
void
checkAddToSelf
(
Component
comp
){
if
(
comp
instanceof
Container
)
{
for
(
Container
cn
=
this
;
cn
!=
null
;
cn
=
cn
.
parent
)
{
if
(
cn
==
comp
)
{
throw
new
IllegalArgumentException
(
"adding container's parent to itself"
);
}
}
}
}
/**
* Checks that the component is not a Window instance.
*/
private
void
checkNotAWindow
(
Component
comp
){
if
(
comp
instanceof
Window
)
{
throw
new
IllegalArgumentException
(
"adding a window to a container"
);
}
}
/**
/**
* Checks that the component comp can be added to this container
* Checks that the component comp can be added to this container
* Checks : index in bounds of container's size,
* Checks : index in bounds of container's size,
...
@@ -437,26 +453,18 @@ public class Container extends Component {
...
@@ -437,26 +453,18 @@ public class Container extends Component {
GraphicsConfiguration
thisGC
=
getGraphicsConfiguration
();
GraphicsConfiguration
thisGC
=
getGraphicsConfiguration
();
if
(
index
>
ncomponents
||
index
<
0
)
{
if
(
index
>
component
.
size
()
||
index
<
0
)
{
throw
new
IllegalArgumentException
(
"illegal component position"
);
throw
new
IllegalArgumentException
(
"illegal component position"
);
}
}
if
(
comp
.
parent
==
this
)
{
if
(
comp
.
parent
==
this
)
{
if
(
index
==
ncomponents
)
{
if
(
index
==
component
.
size
()
)
{
throw
new
IllegalArgumentException
(
"illegal component position "
+
throw
new
IllegalArgumentException
(
"illegal component position "
+
index
+
" should be less then "
+
ncomponents
);
index
+
" should be less then "
+
component
.
size
()
);
}
}
}
}
if
(
comp
instanceof
Container
)
{
checkAddToSelf
(
comp
);
for
(
Container
cn
=
this
;
cn
!=
null
;
cn
=
cn
.
parent
)
{
checkNotAWindow
(
comp
);
if
(
cn
==
comp
)
{
throw
new
IllegalArgumentException
(
"adding container's parent to itself"
);
}
}
if
(
comp
instanceof
Window
)
{
throw
new
IllegalArgumentException
(
"adding a window to a container"
);
}
}
Window
thisTopLevel
=
getContainingWindow
();
Window
thisTopLevel
=
getContainingWindow
();
Window
compTopLevel
=
comp
.
getContainingWindow
();
Window
compTopLevel
=
comp
.
getContainingWindow
();
if
(
thisTopLevel
!=
compTopLevel
)
{
if
(
thisTopLevel
!=
compTopLevel
)
{
...
@@ -495,25 +503,19 @@ public class Container extends Component {
...
@@ -495,25 +503,19 @@ public class Container extends Component {
adjustDescendants
(-(
comp
.
countHierarchyMembers
()));
adjustDescendants
(-(
comp
.
countHierarchyMembers
()));
comp
.
parent
=
null
;
comp
.
parent
=
null
;
System
.
arraycopy
(
component
,
index
+
1
,
component
.
remove
(
index
);
component
,
index
,
ncomponents
-
index
-
1
);
component
[--
ncomponents
]
=
null
;
if
(
valid
)
{
if
(
valid
)
{
invalidate
();
invalidate
();
}
}
}
else
{
}
else
{
if
(
newIndex
>
index
)
{
// 2->4: 012345 -> 013425, 2->5: 012345 -> 013452
// We should remove component and then
if
(
newIndex
-
index
>
0
)
{
// add it by the newIndex without newIndex decrement if even we shift components to the left
System
.
arraycopy
(
component
,
index
+
1
,
component
,
index
,
newIndex
-
index
);
// after remove. Consult the rules below:
}
// 2->4: 012345 -> 013425, 2->5: 012345 -> 013452
}
else
{
// 4->2: 012345 -> 014235
// 4->2: 012345 -> 014235
if
(
index
-
newIndex
>
0
)
{
component
.
remove
(
index
);
System
.
arraycopy
(
component
,
newIndex
,
component
,
newIndex
+
1
,
index
-
newIndex
);
component
.
add
(
newIndex
,
comp
);
}
}
component
[
newIndex
]
=
comp
;
}
}
if
(
comp
.
parent
==
null
)
{
// was actually removed
if
(
comp
.
parent
==
null
)
{
// was actually removed
if
(
containerListener
!=
null
||
if
(
containerListener
!=
null
||
...
@@ -779,17 +781,11 @@ public class Container extends Component {
...
@@ -779,17 +781,11 @@ public class Container extends Component {
// Check if moving between containers
// Check if moving between containers
if
(
curParent
!=
this
)
{
if
(
curParent
!=
this
)
{
/* Add component to list; allocate new array if necessary. */
//index == -1 means add to the end.
if
(
ncomponents
==
component
.
length
)
{
if
(
index
==
-
1
)
{
component
=
Arrays
.
copyOf
(
component
,
ncomponents
*
2
+
1
);
component
.
add
(
comp
);
}
if
(
index
==
-
1
||
index
==
ncomponents
)
{
component
[
ncomponents
++]
=
comp
;
}
else
{
}
else
{
System
.
arraycopy
(
component
,
index
,
component
,
component
.
add
(
index
,
comp
);
index
+
1
,
ncomponents
-
index
);
component
[
index
]
=
comp
;
ncomponents
++;
}
}
comp
.
parent
=
this
;
comp
.
parent
=
this
;
...
@@ -799,8 +795,8 @@ public class Container extends Component {
...
@@ -799,8 +795,8 @@ public class Container extends Component {
comp
.
numListening
(
AWTEvent
.
HIERARCHY_BOUNDS_EVENT_MASK
));
comp
.
numListening
(
AWTEvent
.
HIERARCHY_BOUNDS_EVENT_MASK
));
adjustDescendants
(
comp
.
countHierarchyMembers
());
adjustDescendants
(
comp
.
countHierarchyMembers
());
}
else
{
}
else
{
if
(
index
<
ncomponents
)
{
if
(
index
<
component
.
size
()
)
{
component
[
index
]
=
comp
;
component
.
set
(
index
,
comp
)
;
}
}
}
}
...
@@ -901,14 +897,8 @@ public class Container extends Component {
...
@@ -901,14 +897,8 @@ public class Container extends Component {
if
(
comp
.
parent
!=
this
)
{
if
(
comp
.
parent
!=
this
)
{
return
-
1
;
return
-
1
;
}
}
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
return
component
.
indexOf
(
comp
);
if
(
component
[
i
]
==
comp
)
{
return
i
;
}
}
}
}
// To please javac
return
-
1
;
}
}
/**
/**
...
@@ -1042,22 +1032,12 @@ public class Container extends Component {
...
@@ -1042,22 +1032,12 @@ public class Container extends Component {
*/
*/
GraphicsConfiguration
thisGC
=
this
.
getGraphicsConfiguration
();
GraphicsConfiguration
thisGC
=
this
.
getGraphicsConfiguration
();
if
(
index
>
ncomponents
||
(
index
<
0
&&
index
!=
-
1
))
{
if
(
index
>
component
.
size
()
||
(
index
<
0
&&
index
!=
-
1
))
{
throw
new
IllegalArgumentException
(
throw
new
IllegalArgumentException
(
"illegal component position"
);
"illegal component position"
);
}
}
if
(
comp
instanceof
Container
)
{
checkAddToSelf
(
comp
);
for
(
Container
cn
=
this
;
cn
!=
null
;
cn
=
cn
.
parent
)
{
checkNotAWindow
(
comp
);
if
(
cn
==
comp
)
{
throw
new
IllegalArgumentException
(
"adding container's parent to itself"
);
}
}
if
(
comp
instanceof
Window
)
{
throw
new
IllegalArgumentException
(
"adding a window to a container"
);
}
}
if
(
thisGC
!=
null
)
{
if
(
thisGC
!=
null
)
{
comp
.
checkGD
(
thisGC
.
getDevice
().
getIDstring
());
comp
.
checkGD
(
thisGC
.
getDevice
().
getIDstring
());
}
}
...
@@ -1065,22 +1045,16 @@ public class Container extends Component {
...
@@ -1065,22 +1045,16 @@ public class Container extends Component {
/* Reparent the component and tidy up the tree's state. */
/* Reparent the component and tidy up the tree's state. */
if
(
comp
.
parent
!=
null
)
{
if
(
comp
.
parent
!=
null
)
{
comp
.
parent
.
remove
(
comp
);
comp
.
parent
.
remove
(
comp
);
if
(
index
>
ncomponents
)
{
if
(
index
>
component
.
size
()
)
{
throw
new
IllegalArgumentException
(
"illegal component position"
);
throw
new
IllegalArgumentException
(
"illegal component position"
);
}
}
}
}
/* Add component to list; allocate new array if necessary. */
//index == -1 means add to the end.
if
(
ncomponents
==
component
.
length
)
{
if
(
index
==
-
1
)
{
component
=
Arrays
.
copyOf
(
component
,
ncomponents
*
2
+
1
);
component
.
add
(
comp
);
}
if
(
index
==
-
1
||
index
==
ncomponents
)
{
component
[
ncomponents
++]
=
comp
;
}
else
{
}
else
{
System
.
arraycopy
(
component
,
index
,
component
,
component
.
add
(
index
,
comp
);
index
+
1
,
ncomponents
-
index
);
component
[
index
]
=
comp
;
ncomponents
++;
}
}
comp
.
parent
=
this
;
comp
.
parent
=
this
;
...
@@ -1129,11 +1103,9 @@ public class Container extends Component {
...
@@ -1129,11 +1103,9 @@ public class Container extends Component {
* IllegalArgumentException.
* IllegalArgumentException.
*/
*/
void
checkGD
(
String
stringID
)
{
void
checkGD
(
String
stringID
)
{
Component
tempComp
;
for
(
Component
comp
:
component
)
{
for
(
int
i
=
0
;
i
<
component
.
length
;
i
++)
{
if
(
comp
!=
null
)
{
tempComp
=
component
[
i
];
comp
.
checkGD
(
stringID
);
if
(
tempComp
!=
null
)
{
tempComp
.
checkGD
(
stringID
);
}
}
}
}
}
}
...
@@ -1163,10 +1135,10 @@ public class Container extends Component {
...
@@ -1163,10 +1135,10 @@ public class Container extends Component {
*/
*/
public
void
remove
(
int
index
)
{
public
void
remove
(
int
index
)
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
if
(
index
<
0
||
index
>=
ncomponents
)
{
if
(
index
<
0
||
index
>=
component
.
size
()
)
{
throw
new
ArrayIndexOutOfBoundsException
(
index
);
throw
new
ArrayIndexOutOfBoundsException
(
index
);
}
}
Component
comp
=
component
[
index
]
;
Component
comp
=
component
.
get
(
index
)
;
if
(
peer
!=
null
)
{
if
(
peer
!=
null
)
{
comp
.
removeNotify
();
comp
.
removeNotify
();
}
}
...
@@ -1181,10 +1153,7 @@ public class Container extends Component {
...
@@ -1181,10 +1153,7 @@ public class Container extends Component {
adjustDescendants
(-(
comp
.
countHierarchyMembers
()));
adjustDescendants
(-(
comp
.
countHierarchyMembers
()));
comp
.
parent
=
null
;
comp
.
parent
=
null
;
System
.
arraycopy
(
component
,
index
+
1
,
component
.
remove
(
index
);
component
,
index
,
ncomponents
-
index
-
1
);
component
[--
ncomponents
]
=
null
;
if
(
valid
)
{
if
(
valid
)
{
invalidate
();
invalidate
();
...
@@ -1229,14 +1198,9 @@ public class Container extends Component {
...
@@ -1229,14 +1198,9 @@ public class Container extends Component {
public
void
remove
(
Component
comp
)
{
public
void
remove
(
Component
comp
)
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
if
(
comp
.
parent
==
this
)
{
if
(
comp
.
parent
==
this
)
{
/* Search backwards, expect that more recent additions
int
index
=
component
.
indexOf
(
comp
);
* are more likely to be removed.
if
(
index
>=
0
)
{
*/
remove
(
index
);
Component
component
[]
=
this
.
component
;
for
(
int
i
=
ncomponents
;
--
i
>=
0
;
)
{
if
(
component
[
i
]
==
comp
)
{
remove
(
i
);
}
}
}
}
}
}
}
...
@@ -1258,9 +1222,8 @@ public class Container extends Component {
...
@@ -1258,9 +1222,8 @@ public class Container extends Component {
-
listeningBoundsChildren
);
-
listeningBoundsChildren
);
adjustDescendants
(-
descendantsCount
);
adjustDescendants
(-
descendantsCount
);
while
(
ncomponents
>
0
)
{
while
(!
component
.
isEmpty
())
{
Component
comp
=
component
[--
ncomponents
];
Component
comp
=
component
.
remove
(
component
.
size
()-
1
);
component
[
ncomponents
]
=
null
;
if
(
peer
!=
null
)
{
if
(
peer
!=
null
)
{
comp
.
removeNotify
();
comp
.
removeNotify
();
...
@@ -1300,8 +1263,8 @@ public class Container extends Component {
...
@@ -1300,8 +1263,8 @@ public class Container extends Component {
if
(
eventLog
.
isLoggable
(
Level
.
FINE
))
{
if
(
eventLog
.
isLoggable
(
Level
.
FINE
))
{
// Verify listeningChildren is correct
// Verify listeningChildren is correct
int
sum
=
0
;
int
sum
=
0
;
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++
)
{
for
(
Component
comp
:
component
)
{
sum
+=
comp
onent
[
i
]
.
numListening
(
mask
);
sum
+=
comp
.
numListening
(
mask
);
}
}
if
(
listeningChildren
!=
sum
)
{
if
(
listeningChildren
!=
sum
)
{
eventLog
.
log
(
Level
.
FINE
,
"Assertion (listeningChildren == sum) failed"
);
eventLog
.
log
(
Level
.
FINE
,
"Assertion (listeningChildren == sum) failed"
);
...
@@ -1312,8 +1275,8 @@ public class Container extends Component {
...
@@ -1312,8 +1275,8 @@ public class Container extends Component {
if
(
eventLog
.
isLoggable
(
Level
.
FINE
))
{
if
(
eventLog
.
isLoggable
(
Level
.
FINE
))
{
// Verify listeningBoundsChildren is correct
// Verify listeningBoundsChildren is correct
int
sum
=
0
;
int
sum
=
0
;
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++
)
{
for
(
Component
comp
:
component
)
{
sum
+=
comp
onent
[
i
]
.
numListening
(
mask
);
sum
+=
comp
.
numListening
(
mask
);
}
}
if
(
listeningBoundsChildren
!=
sum
)
{
if
(
listeningBoundsChildren
!=
sum
)
{
eventLog
.
log
(
Level
.
FINE
,
"Assertion (listeningBoundsChildren == sum) failed"
);
eventLog
.
log
(
Level
.
FINE
,
"Assertion (listeningBoundsChildren == sum) failed"
);
...
@@ -1375,8 +1338,8 @@ public class Container extends Component {
...
@@ -1375,8 +1338,8 @@ public class Container extends Component {
if
(
log
.
isLoggable
(
Level
.
FINE
))
{
if
(
log
.
isLoggable
(
Level
.
FINE
))
{
// Verify descendantsCount is correct
// Verify descendantsCount is correct
int
sum
=
0
;
int
sum
=
0
;
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++
)
{
for
(
Component
comp
:
component
)
{
sum
+=
comp
onent
[
i
]
.
countHierarchyMembers
();
sum
+=
comp
.
countHierarchyMembers
();
}
}
if
(
descendantsCount
!=
sum
)
{
if
(
descendantsCount
!=
sum
)
{
log
.
log
(
Level
.
FINE
,
"Assertion (descendantsCount == sum) failed"
);
log
.
log
(
Level
.
FINE
,
"Assertion (descendantsCount == sum) failed"
);
...
@@ -1408,7 +1371,7 @@ public class Container extends Component {
...
@@ -1408,7 +1371,7 @@ public class Container extends Component {
int
listeners
=
getListenersCount
(
id
,
enabledOnToolkit
);
int
listeners
=
getListenersCount
(
id
,
enabledOnToolkit
);
for
(
int
count
=
listeners
,
i
=
0
;
count
>
0
;
i
++)
{
for
(
int
count
=
listeners
,
i
=
0
;
count
>
0
;
i
++)
{
count
-=
component
[
i
]
.
createHierarchyEvents
(
id
,
changed
,
count
-=
component
.
get
(
i
)
.
createHierarchyEvents
(
id
,
changed
,
changedParent
,
changeFlags
,
enabledOnToolkit
);
changedParent
,
changeFlags
,
enabledOnToolkit
);
}
}
return
listeners
+
return
listeners
+
...
@@ -1420,13 +1383,13 @@ public class Container extends Component {
...
@@ -1420,13 +1383,13 @@ public class Container extends Component {
boolean
enabledOnToolkit
)
boolean
enabledOnToolkit
)
{
{
assert
Thread
.
holdsLock
(
getTreeLock
());
assert
Thread
.
holdsLock
(
getTreeLock
());
if
(
ncomponents
==
0
)
{
if
(
component
.
isEmpty
()
)
{
return
;
return
;
}
}
int
listeners
=
getListenersCount
(
id
,
enabledOnToolkit
);
int
listeners
=
getListenersCount
(
id
,
enabledOnToolkit
);
for
(
int
count
=
listeners
,
i
=
0
;
count
>
0
;
i
++)
{
for
(
int
count
=
listeners
,
i
=
0
;
count
>
0
;
i
++)
{
count
-=
component
[
i
]
.
createHierarchyEvents
(
id
,
this
,
parent
,
count
-=
component
.
get
(
i
)
.
createHierarchyEvents
(
id
,
this
,
parent
,
changeFlags
,
enabledOnToolkit
);
changeFlags
,
enabledOnToolkit
);
}
}
}
}
...
@@ -1562,12 +1525,11 @@ public class Container extends Component {
...
@@ -1562,12 +1525,11 @@ public class Container extends Component {
((
ContainerPeer
)
peer
).
beginLayout
();
((
ContainerPeer
)
peer
).
beginLayout
();
}
}
doLayout
();
doLayout
();
Component
component
[]
=
this
.
component
;
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
ncomponents
;
++
i
)
{
Component
comp
=
component
.
get
(
i
);
Component
comp
=
component
[
i
];
if
(
(
comp
instanceof
Container
)
if
(
(
comp
instanceof
Container
)
&&
!(
comp
instanceof
Window
)
&&
!(
comp
instanceof
Window
)
&&
!
comp
.
valid
)
{
&&
!
comp
.
valid
)
{
((
Container
)
comp
).
validateTree
();
((
Container
)
comp
).
validateTree
();
}
else
{
}
else
{
comp
.
validate
();
comp
.
validate
();
...
@@ -1586,8 +1548,8 @@ public class Container extends Component {
...
@@ -1586,8 +1548,8 @@ public class Container extends Component {
*/
*/
void
invalidateTree
()
{
void
invalidateTree
()
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
for
(
int
i
=
0
;
i
<
ncomponents
;
++
i
)
{
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++
)
{
Component
comp
=
component
[
i
]
;
Component
comp
=
component
.
get
(
i
)
;
if
(
comp
instanceof
Container
)
{
if
(
comp
instanceof
Container
)
{
((
Container
)
comp
).
invalidateTree
();
((
Container
)
comp
).
invalidateTree
();
}
}
...
@@ -1838,7 +1800,7 @@ public class Container extends Component {
...
@@ -1838,7 +1800,7 @@ public class Container extends Component {
// super.paint(); -- Don't bother, since it's a NOP.
// super.paint(); -- Don't bother, since it's a NOP.
GraphicsCallback
.
PaintCallback
.
getInstance
().
GraphicsCallback
.
PaintCallback
.
getInstance
().
runComponents
(
component
,
g
,
GraphicsCallback
.
LIGHTWEIGHTS
);
runComponents
(
component
.
toArray
(
EMPTY_ARRAY
)
,
g
,
GraphicsCallback
.
LIGHTWEIGHTS
);
}
}
}
}
...
@@ -1893,7 +1855,7 @@ public class Container extends Component {
...
@@ -1893,7 +1855,7 @@ public class Container extends Component {
}
}
GraphicsCallback
.
PrintCallback
.
getInstance
().
GraphicsCallback
.
PrintCallback
.
getInstance
().
runComponents
(
component
,
g
,
GraphicsCallback
.
LIGHTWEIGHTS
);
runComponents
(
component
.
toArray
(
EMPTY_ARRAY
)
,
g
,
GraphicsCallback
.
LIGHTWEIGHTS
);
}
}
}
}
...
@@ -1906,7 +1868,7 @@ public class Container extends Component {
...
@@ -1906,7 +1868,7 @@ public class Container extends Component {
public
void
paintComponents
(
Graphics
g
)
{
public
void
paintComponents
(
Graphics
g
)
{
if
(
isShowing
())
{
if
(
isShowing
())
{
GraphicsCallback
.
PaintAllCallback
.
getInstance
().
GraphicsCallback
.
PaintAllCallback
.
getInstance
().
runComponents
(
component
,
g
,
GraphicsCallback
.
TWO_PASSES
);
runComponents
(
component
.
toArray
(
EMPTY_ARRAY
)
,
g
,
GraphicsCallback
.
TWO_PASSES
);
}
}
}
}
...
@@ -1928,7 +1890,7 @@ public class Container extends Component {
...
@@ -1928,7 +1890,7 @@ public class Container extends Component {
void
paintHeavyweightComponents
(
Graphics
g
)
{
void
paintHeavyweightComponents
(
Graphics
g
)
{
if
(
isShowing
())
{
if
(
isShowing
())
{
GraphicsCallback
.
PaintHeavyweightComponentsCallback
.
getInstance
().
GraphicsCallback
.
PaintHeavyweightComponentsCallback
.
getInstance
().
runComponents
(
component
,
g
,
GraphicsCallback
.
LIGHTWEIGHTS
|
runComponents
(
component
.
toArray
(
EMPTY_ARRAY
)
,
g
,
GraphicsCallback
.
LIGHTWEIGHTS
|
GraphicsCallback
.
HEAVYWEIGHTS
);
GraphicsCallback
.
HEAVYWEIGHTS
);
}
}
}
}
...
@@ -1942,7 +1904,7 @@ public class Container extends Component {
...
@@ -1942,7 +1904,7 @@ public class Container extends Component {
public
void
printComponents
(
Graphics
g
)
{
public
void
printComponents
(
Graphics
g
)
{
if
(
isShowing
())
{
if
(
isShowing
())
{
GraphicsCallback
.
PrintAllCallback
.
getInstance
().
GraphicsCallback
.
PrintAllCallback
.
getInstance
().
runComponents
(
component
,
g
,
GraphicsCallback
.
TWO_PASSES
);
runComponents
(
component
.
toArray
(
EMPTY_ARRAY
)
,
g
,
GraphicsCallback
.
TWO_PASSES
);
}
}
}
}
...
@@ -1964,7 +1926,7 @@ public class Container extends Component {
...
@@ -1964,7 +1926,7 @@ public class Container extends Component {
void
printHeavyweightComponents
(
Graphics
g
)
{
void
printHeavyweightComponents
(
Graphics
g
)
{
if
(
isShowing
())
{
if
(
isShowing
())
{
GraphicsCallback
.
PrintHeavyweightComponentsCallback
.
getInstance
().
GraphicsCallback
.
PrintHeavyweightComponentsCallback
.
getInstance
().
runComponents
(
component
,
g
,
GraphicsCallback
.
LIGHTWEIGHTS
|
runComponents
(
component
.
toArray
(
EMPTY_ARRAY
)
,
g
,
GraphicsCallback
.
LIGHTWEIGHTS
|
GraphicsCallback
.
HEAVYWEIGHTS
);
GraphicsCallback
.
HEAVYWEIGHTS
);
}
}
}
}
...
@@ -2260,11 +2222,9 @@ public class Container extends Component {
...
@@ -2260,11 +2222,9 @@ public class Container extends Component {
boolean
searchHeavyweightChildren
,
boolean
searchHeavyweightChildren
,
boolean
searchHeavyweightDescendants
)
{
boolean
searchHeavyweightDescendants
)
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
int
ncomponents
=
this
.
ncomponents
;
Component
component
[]
=
this
.
component
;
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
for
(
int
i
=
0
;
i
<
component
.
size
()
;
i
++)
{
Component
comp
=
component
[
i
]
;
Component
comp
=
component
.
get
(
i
)
;
if
(
comp
!=
null
&&
comp
.
visible
&&
if
(
comp
!=
null
&&
comp
.
visible
&&
((!
searchHeavyweightChildren
&&
((!
searchHeavyweightChildren
&&
comp
.
peer
instanceof
LightweightPeer
)
||
comp
.
peer
instanceof
LightweightPeer
)
||
...
@@ -2415,8 +2375,8 @@ public class Container extends Component {
...
@@ -2415,8 +2375,8 @@ public class Container extends Component {
}
}
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
// Two passes: see comment in sun.awt.SunGraphicsCallback
// Two passes: see comment in sun.awt.SunGraphicsCallback
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
for
(
int
i
=
0
;
i
<
component
.
size
()
;
i
++)
{
Component
comp
=
component
[
i
]
;
Component
comp
=
component
.
get
(
i
)
;
if
(
comp
!=
null
&&
if
(
comp
!=
null
&&
!(
comp
.
peer
instanceof
LightweightPeer
))
{
!(
comp
.
peer
instanceof
LightweightPeer
))
{
if
(
comp
.
contains
(
x
-
comp
.
x
,
y
-
comp
.
y
))
{
if
(
comp
.
contains
(
x
-
comp
.
x
,
y
-
comp
.
y
))
{
...
@@ -2424,8 +2384,8 @@ public class Container extends Component {
...
@@ -2424,8 +2384,8 @@ public class Container extends Component {
}
}
}
}
}
}
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
for
(
int
i
=
0
;
i
<
component
.
size
()
;
i
++)
{
Component
comp
=
component
[
i
]
;
Component
comp
=
component
.
get
(
i
)
;
if
(
comp
!=
null
&&
if
(
comp
!=
null
&&
comp
.
peer
instanceof
LightweightPeer
)
{
comp
.
peer
instanceof
LightweightPeer
)
{
if
(
comp
.
contains
(
x
-
comp
.
x
,
y
-
comp
.
y
))
{
if
(
comp
.
contains
(
x
-
comp
.
x
,
y
-
comp
.
y
))
{
...
@@ -2544,43 +2504,43 @@ public class Container extends Component {
...
@@ -2544,43 +2504,43 @@ public class Container extends Component {
if
(!(
contains
(
x
,
y
)
&&
visible
&&
(
ignoreEnabled
||
enabled
)))
{
if
(!(
contains
(
x
,
y
)
&&
visible
&&
(
ignoreEnabled
||
enabled
)))
{
return
null
;
return
null
;
}
}
int
ncomponents
=
this
.
ncomponents
;
Component
component
[]
=
this
.
component
;
// Two passes: see comment in sun.awt.SunGraphicsCallback
// Two passes: see comment in sun.awt.SunGraphicsCallback
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
synchronized
(
getTreeLock
())
{
Component
comp
=
component
[
i
];
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
if
(
comp
!=
null
&&
Component
comp
=
component
.
get
(
i
);
!(
comp
.
peer
instanceof
LightweightPeer
))
{
if
(
comp
!=
null
&&
if
(
comp
instanceof
Container
)
{
!(
comp
.
peer
instanceof
LightweightPeer
))
{
comp
=
((
Container
)
comp
).
findComponentAtImpl
(
x
-
comp
.
x
,
if
(
comp
instanceof
Container
)
{
y
-
comp
.
y
,
comp
=
((
Container
)
comp
).
findComponentAtImpl
(
x
-
comp
.
x
,
ignoreEnabled
);
y
-
comp
.
y
,
}
else
{
ignoreEnabled
);
comp
=
comp
.
locate
(
x
-
comp
.
x
,
y
-
comp
.
y
);
}
else
{
}
comp
=
comp
.
locate
(
x
-
comp
.
x
,
y
-
comp
.
y
);
if
(
comp
!=
null
&&
comp
.
visible
&&
}
(
ignoreEnabled
||
comp
.
enabled
))
if
(
comp
!=
null
&&
comp
.
visible
&&
{
(
ignoreEnabled
||
comp
.
enabled
))
return
comp
;
{
return
comp
;
}
}
}
}
}
}
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
Component
comp
=
component
.
get
(
i
);
Component
comp
=
component
[
i
];
if
(
comp
!=
null
&&
if
(
comp
!=
null
&&
comp
.
peer
instanceof
LightweightPeer
)
{
comp
.
peer
instanceof
LightweightPe
er
)
{
if
(
comp
instanceof
Contain
er
)
{
if
(
comp
instanceof
Container
)
{
comp
=
((
Container
)
comp
).
findComponentAtImpl
(
x
-
comp
.
x
,
comp
=
((
Container
)
comp
).
findComponentAtImpl
(
x
-
comp
.
x
,
y
-
comp
.
y
,
y
-
comp
.
y
,
ignoreEnabled
);
ignoreEnabled
);
}
else
{
}
else
{
comp
=
comp
.
locate
(
x
-
comp
.
x
,
y
-
comp
.
y
);
comp
=
comp
.
locate
(
x
-
comp
.
x
,
y
-
comp
.
y
);
}
}
if
(
comp
!=
null
&&
comp
.
visible
&&
if
(
comp
!=
null
&&
comp
.
visible
&&
(
ignoreEnabled
||
comp
.
enabled
))
(
ignoreEnabled
||
comp
.
enabled
))
{
{
return
comp
;
return
comp
;
}
}
}
}
}
}
}
...
@@ -2632,10 +2592,14 @@ public class Container extends Component {
...
@@ -2632,10 +2592,14 @@ public class Container extends Component {
if
(!
(
peer
instanceof
LightweightPeer
))
{
if
(!
(
peer
instanceof
LightweightPeer
))
{
dispatcher
=
new
LightweightDispatcher
(
this
);
dispatcher
=
new
LightweightDispatcher
(
this
);
}
}
int
ncomponents
=
this
.
ncomponents
;
Component
component
[]
=
this
.
component
;
// We shouldn't use iterator because of the Swing menu
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
// implementation specifics:
component
[
i
].
addNotify
();
// the menu is being assigned as a child to JLayeredPane
// instead of particular component so always affect
// collection of component if menu is becoming shown or hidden.
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
component
.
get
(
i
).
addNotify
();
}
}
// Update stacking order if native platform allows
// Update stacking order if native platform allows
ContainerPeer
cpeer
=
(
ContainerPeer
)
peer
;
ContainerPeer
cpeer
=
(
ContainerPeer
)
peer
;
...
@@ -2658,21 +2622,25 @@ public class Container extends Component {
...
@@ -2658,21 +2622,25 @@ public class Container extends Component {
*/
*/
public
void
removeNotify
()
{
public
void
removeNotify
()
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
int
ncomponents
=
this
.
ncomponents
;
// We shouldn't use iterator because of the Swing menu
Component
component
[]
=
this
.
component
;
// implementation specifics:
for
(
int
i
=
ncomponents
-
1
;
i
>=
0
;
i
--)
{
// the menu is being assigned as a child to JLayeredPane
if
(
component
[
i
]
!=
null
)
{
// instead of particular component so always affect
// collection of component if menu is becoming shown or hidden.
for
(
int
i
=
component
.
size
()-
1
;
i
>=
0
;
i
--)
{
Component
comp
=
component
.
get
(
i
);
if
(
comp
!=
null
)
{
// Fix for 6607170.
// Fix for 6607170.
// We want to suppress focus change on disposal
// We want to suppress focus change on disposal
// of the focused component. But because of focus
// of the focused component. But because of focus
// is asynchronous, we should suppress focus change
// is asynchronous, we should suppress focus change
// on every component in case it receives native focus
// on every component in case it receives native focus
// in the process of disposal.
// in the process of disposal.
comp
onent
[
i
]
.
setAutoFocusTransferOnDisposal
(
false
);
comp
.
setAutoFocusTransferOnDisposal
(
false
);
comp
onent
[
i
]
.
removeNotify
();
comp
.
removeNotify
();
comp
onent
[
i
]
.
setAutoFocusTransferOnDisposal
(
true
);
comp
.
setAutoFocusTransferOnDisposal
(
true
);
}
}
}
}
// If some of the children had focus before disposal then it still has.
// If some of the children had focus before disposal then it still has.
// Auto-transfer focus to the next (or previous) component if auto-transfer
// Auto-transfer focus to the next (or previous) component if auto-transfer
// is enabled.
// is enabled.
...
@@ -2683,7 +2651,7 @@ public class Container extends Component {
...
@@ -2683,7 +2651,7 @@ public class Container extends Component {
}
}
if
(
dispatcher
!=
null
)
{
if
(
dispatcher
!=
null
)
{
dispatcher
.
dispose
();
dispatcher
.
dispose
();
dispatcher
=
null
;
dispatcher
=
null
;
}
}
super
.
removeNotify
();
super
.
removeNotify
();
}
}
...
@@ -2873,12 +2841,12 @@ public class Container extends Component {
...
@@ -2873,12 +2841,12 @@ public class Container extends Component {
*/
*/
public
void
list
(
PrintStream
out
,
int
indent
)
{
public
void
list
(
PrintStream
out
,
int
indent
)
{
super
.
list
(
out
,
indent
);
super
.
list
(
out
,
indent
);
int
ncomponents
=
this
.
ncomponents
;
synchronized
(
getTreeLock
())
{
Component
component
[]
=
this
.
component
;
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
Component
comp
=
component
.
get
(
i
);
Component
comp
=
component
[
i
];
if
(
comp
!=
null
)
{
if
(
comp
!=
null
)
{
comp
.
list
(
out
,
indent
+
1
);
comp
.
list
(
out
,
indent
+
1
);
}
}
}
}
}
}
}
...
@@ -2899,12 +2867,12 @@ public class Container extends Component {
...
@@ -2899,12 +2867,12 @@ public class Container extends Component {
*/
*/
public
void
list
(
PrintWriter
out
,
int
indent
)
{
public
void
list
(
PrintWriter
out
,
int
indent
)
{
super
.
list
(
out
,
indent
);
super
.
list
(
out
,
indent
);
int
ncomponents
=
this
.
ncomponents
;
synchronized
(
getTreeLock
())
{
Component
component
[]
=
this
.
component
;
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
Component
comp
=
component
.
get
(
i
);
Component
comp
=
component
[
i
];
if
(
comp
!=
null
)
{
if
(
comp
!=
null
)
{
comp
.
list
(
out
,
indent
+
1
);
comp
.
list
(
out
,
indent
+
1
);
}
}
}
}
}
}
}
...
@@ -3414,9 +3382,11 @@ public class Container extends Component {
...
@@ -3414,9 +3382,11 @@ public class Container extends Component {
*/
*/
public
void
applyComponentOrientation
(
ComponentOrientation
o
)
{
public
void
applyComponentOrientation
(
ComponentOrientation
o
)
{
super
.
applyComponentOrientation
(
o
);
super
.
applyComponentOrientation
(
o
);
synchronized
(
getTreeLock
())
{
for
(
int
i
=
0
;
i
<
ncomponents
;
++
i
)
{
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
component
[
i
].
applyComponentOrientation
(
o
);
Component
comp
=
component
.
get
(
i
);
comp
.
applyComponentOrientation
(
o
);
}
}
}
}
}
...
@@ -3534,8 +3504,8 @@ public class Container extends Component {
...
@@ -3534,8 +3504,8 @@ public class Container extends Component {
*/
*/
private
void
writeObject
(
ObjectOutputStream
s
)
throws
IOException
{
private
void
writeObject
(
ObjectOutputStream
s
)
throws
IOException
{
ObjectOutputStream
.
PutField
f
=
s
.
putFields
();
ObjectOutputStream
.
PutField
f
=
s
.
putFields
();
f
.
put
(
"ncomponents"
,
ncomponents
);
f
.
put
(
"ncomponents"
,
component
.
size
()
);
f
.
put
(
"component"
,
component
);
f
.
put
(
"component"
,
component
.
toArray
(
EMPTY_ARRAY
)
);
f
.
put
(
"layoutMgr"
,
layoutMgr
);
f
.
put
(
"layoutMgr"
,
layoutMgr
);
f
.
put
(
"dispatcher"
,
dispatcher
);
f
.
put
(
"dispatcher"
,
dispatcher
);
f
.
put
(
"maxSize"
,
maxSize
);
f
.
put
(
"maxSize"
,
maxSize
);
...
@@ -3574,8 +3544,12 @@ public class Container extends Component {
...
@@ -3574,8 +3544,12 @@ public class Container extends Component {
throws
ClassNotFoundException
,
IOException
throws
ClassNotFoundException
,
IOException
{
{
ObjectInputStream
.
GetField
f
=
s
.
readFields
();
ObjectInputStream
.
GetField
f
=
s
.
readFields
();
ncomponents
=
f
.
get
(
"ncomponents"
,
0
);
Component
[]
tmpComponent
=
(
Component
[])
f
.
get
(
"component"
,
EMPTY_ARRAY
);
component
=
(
Component
[])
f
.
get
(
"component"
,
new
Component
[
0
]);
int
ncomponents
=
(
Integer
)
f
.
get
(
"ncomponents"
,
0
);
component
=
new
java
.
util
.
ArrayList
<
Component
>(
ncomponents
);
for
(
int
i
=
0
;
i
<
ncomponents
;
++
i
)
{
component
.
add
(
tmpComponent
[
i
]);
}
layoutMgr
=
(
LayoutManager
)
f
.
get
(
"layoutMgr"
,
null
);
layoutMgr
=
(
LayoutManager
)
f
.
get
(
"layoutMgr"
,
null
);
dispatcher
=
(
LightweightDispatcher
)
f
.
get
(
"dispatcher"
,
null
);
dispatcher
=
(
LightweightDispatcher
)
f
.
get
(
"dispatcher"
,
null
);
// Old stream. Doesn't contain maxSize among Component's fields.
// Old stream. Doesn't contain maxSize among Component's fields.
...
@@ -3585,16 +3559,14 @@ public class Container extends Component {
...
@@ -3585,16 +3559,14 @@ public class Container extends Component {
focusCycleRoot
=
f
.
get
(
"focusCycleRoot"
,
false
);
focusCycleRoot
=
f
.
get
(
"focusCycleRoot"
,
false
);
containerSerializedDataVersion
=
f
.
get
(
"containerSerializedDataVersion"
,
1
);
containerSerializedDataVersion
=
f
.
get
(
"containerSerializedDataVersion"
,
1
);
focusTraversalPolicyProvider
=
f
.
get
(
"focusTraversalPolicyProvider"
,
false
);
focusTraversalPolicyProvider
=
f
.
get
(
"focusTraversalPolicyProvider"
,
false
);
java
.
util
.
List
<
Component
>
component
=
this
.
component
;
Component
component
[]
=
this
.
component
;
for
(
Component
comp
:
component
)
{
for
(
int
i
=
0
;
i
<
ncomponents
;
i
++)
{
comp
.
parent
=
this
;
component
[
i
].
parent
=
this
;
adjustListeningChildren
(
AWTEvent
.
HIERARCHY_EVENT_MASK
,
adjustListeningChildren
(
AWTEvent
.
HIERARCHY_EVENT_MASK
,
component
[
i
]
.
numListening
(
AWTEvent
.
HIERARCHY_EVENT_MASK
));
comp
.
numListening
(
AWTEvent
.
HIERARCHY_EVENT_MASK
));
adjustListeningChildren
(
AWTEvent
.
HIERARCHY_BOUNDS_EVENT_MASK
,
adjustListeningChildren
(
AWTEvent
.
HIERARCHY_BOUNDS_EVENT_MASK
,
component
[
i
].
numListening
(
comp
.
numListening
(
AWTEvent
.
HIERARCHY_BOUNDS_EVENT_MASK
));
AWTEvent
.
HIERARCHY_BOUNDS_EVENT_MASK
));
adjustDescendants
(
comp
.
countHierarchyMembers
());
adjustDescendants
(
component
[
i
].
countHierarchyMembers
());
}
}
Object
keyOrNull
;
Object
keyOrNull
;
...
...
src/share/classes/java/awt/ScrollPane.java
浏览文件 @
a0158dbd
...
@@ -357,7 +357,7 @@ public class ScrollPane extends Container implements Accessible {
...
@@ -357,7 +357,7 @@ public class ScrollPane extends Container implements Accessible {
*/
*/
public
void
setScrollPosition
(
int
x
,
int
y
)
{
public
void
setScrollPosition
(
int
x
,
int
y
)
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
if
(
ncomponents
<=
0
)
{
if
(
getComponentCount
()==
0
)
{
throw
new
NullPointerException
(
"child is null"
);
throw
new
NullPointerException
(
"child is null"
);
}
}
hAdjustable
.
setValue
(
x
);
hAdjustable
.
setValue
(
x
);
...
@@ -393,10 +393,12 @@ public class ScrollPane extends Container implements Accessible {
...
@@ -393,10 +393,12 @@ public class ScrollPane extends Container implements Accessible {
*/
*/
@Transient
@Transient
public
Point
getScrollPosition
()
{
public
Point
getScrollPosition
()
{
if
(
ncomponents
<=
0
)
{
synchronized
(
getTreeLock
())
{
throw
new
NullPointerException
(
"child is null"
);
if
(
getComponentCount
()==
0
)
{
throw
new
NullPointerException
(
"child is null"
);
}
return
new
Point
(
hAdjustable
.
getValue
(),
vAdjustable
.
getValue
());
}
}
return
new
Point
(
hAdjustable
.
getValue
(),
vAdjustable
.
getValue
());
}
}
/**
/**
...
@@ -486,26 +488,27 @@ public class ScrollPane extends Container implements Accessible {
...
@@ -486,26 +488,27 @@ public class ScrollPane extends Container implements Accessible {
*/
*/
@Deprecated
@Deprecated
public
void
layout
()
{
public
void
layout
()
{
if
(
ncomponents
>
0
)
{
if
(
getComponentCount
()==
0
)
{
Component
c
=
getComponent
(
0
);
return
;
Point
p
=
getScrollPosition
();
}
Dimension
cs
=
calculateChildSize
();
Component
c
=
getComponent
(
0
);
Dimension
vs
=
getViewportSize
();
Point
p
=
getScrollPosition
();
Insets
i
=
getInsets
();
Dimension
cs
=
calculateChildSize
();
Dimension
vs
=
getViewportSize
();
c
.
reshape
(
i
.
left
-
p
.
x
,
i
.
top
-
p
.
y
,
cs
.
width
,
cs
.
height
);
Insets
i
=
getInsets
();
ScrollPanePeer
peer
=
(
ScrollPanePeer
)
this
.
peer
;
if
(
peer
!=
null
)
{
peer
.
childResized
(
cs
.
width
,
cs
.
height
);
}
// update adjustables... the viewport size may have changed
c
.
reshape
(
i
.
left
-
p
.
x
,
i
.
top
-
p
.
y
,
cs
.
width
,
cs
.
height
);
// with the scrollbars coming or going so the viewport size
ScrollPanePeer
peer
=
(
ScrollPanePeer
)
this
.
peer
;
// is updated before the adjustables.
if
(
peer
!=
null
)
{
vs
=
getViewportSize
();
peer
.
childResized
(
cs
.
width
,
cs
.
height
);
hAdjustable
.
setSpan
(
0
,
cs
.
width
,
vs
.
width
);
vAdjustable
.
setSpan
(
0
,
cs
.
height
,
vs
.
height
);
}
}
// update adjustables... the viewport size may have changed
// with the scrollbars coming or going so the viewport size
// is updated before the adjustables.
vs
=
getViewportSize
();
hAdjustable
.
setSpan
(
0
,
cs
.
width
,
vs
.
width
);
vAdjustable
.
setSpan
(
0
,
cs
.
height
,
vs
.
height
);
}
}
/**
/**
...
@@ -515,20 +518,21 @@ public class ScrollPane extends Container implements Accessible {
...
@@ -515,20 +518,21 @@ public class ScrollPane extends Container implements Accessible {
* @see Component#printAll
* @see Component#printAll
*/
*/
public
void
printComponents
(
Graphics
g
)
{
public
void
printComponents
(
Graphics
g
)
{
if
(
ncomponents
>
0
)
{
if
(
getComponentCount
()==
0
)
{
Component
c
=
component
[
0
];
return
;
Point
p
=
c
.
getLocation
();
}
Dimension
vs
=
getViewportSize
();
Component
c
=
getComponent
(
0
);
Insets
i
=
getInsets
();
Point
p
=
c
.
getLocation
();
Dimension
vs
=
getViewportSize
();
Graphics
cg
=
g
.
create
();
Insets
i
=
getInsets
();
try
{
cg
.
clipRect
(
i
.
left
,
i
.
top
,
vs
.
width
,
vs
.
height
);
Graphics
cg
=
g
.
create
();
cg
.
translate
(
p
.
x
,
p
.
y
);
try
{
c
.
printAll
(
cg
);
cg
.
clipRect
(
i
.
left
,
i
.
top
,
vs
.
width
,
vs
.
height
);
}
finally
{
cg
.
translate
(
p
.
x
,
p
.
y
);
cg
.
dispose
();
c
.
printAll
(
cg
);
}
}
finally
{
cg
.
dispose
();
}
}
}
}
...
@@ -589,7 +593,7 @@ public class ScrollPane extends Container implements Accessible {
...
@@ -589,7 +593,7 @@ public class ScrollPane extends Container implements Accessible {
default
:
default
:
sdpStr
=
"invalid display policy"
;
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
();
Insets
i
=
getInsets
();
return
super
.
paramString
()+
",ScrollPosition=("
+
p
.
x
+
","
+
p
.
y
+
")"
+
return
super
.
paramString
()+
",ScrollPosition=("
+
p
.
x
+
","
+
p
.
y
+
")"
+
",Insets=("
+
i
.
top
+
","
+
i
.
left
+
","
+
i
.
bottom
+
","
+
i
.
right
+
")"
+
",Insets=("
+
i
.
top
+
","
+
i
.
left
+
","
+
i
.
bottom
+
","
+
i
.
right
+
")"
+
...
...
src/windows/native/sun/windows/awt_Container.cpp
浏览文件 @
a0158dbd
/*
/*
* Copyright 1998-200
0
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-200
8
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -30,8 +30,6 @@
...
@@ -30,8 +30,6 @@
* AwtContainer fields
* AwtContainer fields
*/
*/
jfieldID
AwtContainer
::
ncomponentsID
;
jfieldID
AwtContainer
::
componentID
;
jfieldID
AwtContainer
::
layoutMgrID
;
jfieldID
AwtContainer
::
layoutMgrID
;
jmethodID
AwtContainer
::
findComponentAtMID
;
jmethodID
AwtContainer
::
findComponentAtMID
;
...
@@ -45,18 +43,12 @@ JNIEXPORT void JNICALL
...
@@ -45,18 +43,12 @@ JNIEXPORT void JNICALL
Java_java_awt_Container_initIDs
(
JNIEnv
*
env
,
jclass
cls
)
{
Java_java_awt_Container_initIDs
(
JNIEnv
*
env
,
jclass
cls
)
{
TRY
;
TRY
;
AwtContainer
::
ncomponentsID
=
env
->
GetFieldID
(
cls
,
"ncomponents"
,
"I"
);
AwtContainer
::
componentID
=
env
->
GetFieldID
(
cls
,
"component"
,
"[Ljava/awt/Component;"
);
AwtContainer
::
layoutMgrID
=
AwtContainer
::
layoutMgrID
=
env
->
GetFieldID
(
cls
,
"layoutMgr"
,
"Ljava/awt/LayoutManager;"
);
env
->
GetFieldID
(
cls
,
"layoutMgr"
,
"Ljava/awt/LayoutManager;"
);
AwtContainer
::
findComponentAtMID
=
AwtContainer
::
findComponentAtMID
=
env
->
GetMethodID
(
cls
,
"findComponentAt"
,
"(IIZ)Ljava/awt/Component;"
);
env
->
GetMethodID
(
cls
,
"findComponentAt"
,
"(IIZ)Ljava/awt/Component;"
);
DASSERT
(
AwtContainer
::
ncomponentsID
!=
NULL
);
DASSERT
(
AwtContainer
::
componentID
!=
NULL
);
DASSERT
(
AwtContainer
::
layoutMgrID
!=
NULL
);
DASSERT
(
AwtContainer
::
layoutMgrID
!=
NULL
);
DASSERT
(
AwtContainer
::
findComponentAtMID
);
DASSERT
(
AwtContainer
::
findComponentAtMID
);
...
...
src/windows/native/sun/windows/awt_Container.h
浏览文件 @
a0158dbd
/*
/*
* 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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -37,8 +37,6 @@ class AwtContainer {
...
@@ -37,8 +37,6 @@ class AwtContainer {
public:
public:
/* java.awt.Container field ids */
/* java.awt.Container field ids */
static
jfieldID
ncomponentsID
;
static
jfieldID
componentID
;
static
jfieldID
layoutMgrID
;
static
jfieldID
layoutMgrID
;
static
jmethodID
findComponentAtMID
;
static
jmethodID
findComponentAtMID
;
...
...
test/java/awt/Container/CheckZOrderChange/CheckZOrderChange.java
0 → 100644
浏览文件 @
a0158dbd
/*
@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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录