Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
44ab7618
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
44ab7618
编写于
10月 20, 2010
作者:
A
alexp
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6989617: Enable JComponent to control repaintings of its children
Reviewed-by: rupashka
上级
3eff6911
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
132 addition
and
21 deletion
+132
-21
src/share/classes/javax/swing/JComponent.java
src/share/classes/javax/swing/JComponent.java
+12
-15
src/share/classes/javax/swing/JLayer.java
src/share/classes/javax/swing/JLayer.java
+1
-1
src/share/classes/javax/swing/JViewport.java
src/share/classes/javax/swing/JViewport.java
+5
-5
src/share/classes/javax/swing/RepaintManager.java
src/share/classes/javax/swing/RepaintManager.java
+11
-0
test/javax/swing/JComponent/6989617/bug6989617.java
test/javax/swing/JComponent/6989617/bug6989617.java
+103
-0
未找到文件。
src/share/classes/javax/swing/JComponent.java
浏览文件 @
44ab7618
...
...
@@ -4783,21 +4783,11 @@ public abstract class JComponent extends Container implements Serializable,
* @param y the y value of the dirty region
* @param width the width of the dirty region
* @param height the height of the dirty region
* @see #isPaintingOrigin()
* @see java.awt.Component#isShowing
* @see RepaintManager#addDirtyRegion
*/
public
void
repaint
(
long
tm
,
int
x
,
int
y
,
int
width
,
int
height
)
{
Container
p
=
this
;
while
((
p
=
p
.
getParent
())
instanceof
JComponent
)
{
JComponent
jp
=
(
JComponent
)
p
;
if
(
jp
.
isPaintingOrigin
())
{
Rectangle
rectangle
=
SwingUtilities
.
convertRectangle
(
this
,
new
Rectangle
(
x
,
y
,
width
,
height
),
jp
);
jp
.
repaint
(
tm
,
rectangle
.
x
,
rectangle
.
y
,
rectangle
.
width
,
rectangle
.
height
);
return
;
}
}
RepaintManager
.
currentManager
(
this
).
addDirtyRegion
(
this
,
x
,
y
,
width
,
height
);
}
...
...
@@ -4808,6 +4798,7 @@ public abstract class JComponent extends Container implements Serializable,
* currently pending events have been dispatched.
*
* @param r a <code>Rectangle</code> containing the dirty region
* @see #isPaintingOrigin()
* @see java.awt.Component#isShowing
* @see RepaintManager#addDirtyRegion
*/
...
...
@@ -4912,13 +4903,19 @@ public abstract class JComponent extends Container implements Serializable,
}
/**
* Returns
true
if a paint triggered on a child component should cause
* Returns
{@code true}
if a paint triggered on a child component should cause
* painting to originate from this Component, or one of its ancestors.
* <p/>
* Calling {@link JComponent#repaint} on a Swing component will be delegated to
* the first ancestor which {@code isPaintingOrigin()} returns {@true},
* if there are any.
* <p/>
* {@code JComponent} subclasses that need to be repainted when any of their
* children are repainted should override this method to return {@code true}.
*
* @return true if painting should originate from this Component or
* one of its ancestors.
* @return always returns {@code false}
*/
boolean
isPaintingOrigin
()
{
protected
boolean
isPaintingOrigin
()
{
return
false
;
}
...
...
src/share/classes/javax/swing/JLayer.java
浏览文件 @
44ab7618
...
...
@@ -384,7 +384,7 @@ public final class JLayer<V extends Component>
* @return true
* @see JComponent#isPaintingOrigin()
*/
boolean
isPaintingOrigin
()
{
protected
boolean
isPaintingOrigin
()
{
return
true
;
}
...
...
src/share/classes/javax/swing/JViewport.java
浏览文件 @
44ab7618
...
...
@@ -637,14 +637,14 @@ public class JViewport extends JComponent implements Accessible
}
/**
* Returns true if scroll mode is a
BACKINGSTORE_SCROLL_MODE
to cause
* painting to originate from
<code>JViewport</code>
, or one of its
* ancestors. Otherwise returns
false
.
* Returns true if scroll mode is a
{@code BACKINGSTORE_SCROLL_MODE}
to cause
* painting to originate from
{@code JViewport}
, or one of its
* ancestors. Otherwise returns
{@code false}
.
*
* @return true if if scroll mode is a
BACKINGSTORE_SCROLL_MODE
.
* @return true if if scroll mode is a
{@code BACKINGSTORE_SCROLL_MODE}
.
* @see JComponent#isPaintingOrigin()
*/
boolean
isPaintingOrigin
()
{
protected
boolean
isPaintingOrigin
()
{
return
scrollMode
==
BACKINGSTORE_SCROLL_MODE
;
}
...
...
src/share/classes/javax/swing/RepaintManager.java
浏览文件 @
44ab7618
...
...
@@ -438,6 +438,7 @@ public class RepaintManager
* @param y Y coordinate of the region to repaint
* @param w Width of the region to repaint
* @param h Height of the region to repaint
* @see JComponent#isPaintingOrigin()
* @see JComponent#repaint
*/
public
void
addDirtyRegion
(
JComponent
c
,
int
x
,
int
y
,
int
w
,
int
h
)
...
...
@@ -447,6 +448,16 @@ public class RepaintManager
delegate
.
addDirtyRegion
(
c
,
x
,
y
,
w
,
h
);
return
;
}
Container
p
=
c
;
while
((
p
=
p
.
getParent
())
instanceof
JComponent
)
{
JComponent
jp
=
(
JComponent
)
p
;
if
(
jp
.
isPaintingOrigin
())
{
Rectangle
rectangle
=
SwingUtilities
.
convertRectangle
(
c
,
new
Rectangle
(
x
,
y
,
w
,
h
),
jp
);
jp
.
repaint
(
0
,
rectangle
.
x
,
rectangle
.
y
,
rectangle
.
width
,
rectangle
.
height
);
return
;
}
}
addDirtyRegion0
(
c
,
x
,
y
,
w
,
h
);
}
...
...
test/javax/swing/JComponent/6989617/bug6989617.java
0 → 100644
浏览文件 @
44ab7618
/*
* Copyright (c) 2010, Oracle and/or its affiliates. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 6989617
@summary Enable JComponent to control repaintings of its children
@author Alexander Potochkin
@run main bug6989617
*/
import
javax.swing.*
;
import
java.awt.*
;
public
class
bug6989617
{
private
boolean
isPaintingOrigin
;
private
boolean
innerPanelRepainted
,
outerPanelRepainted
;
public
bug6989617
()
{
final
JButton
button
=
new
JButton
(
"button"
);
JPanel
innerPanel
=
new
JPanel
()
{
protected
boolean
isPaintingOrigin
()
{
return
isPaintingOrigin
;
}
public
void
repaint
(
long
tm
,
int
x
,
int
y
,
int
width
,
int
height
)
{
if
(
button
.
getParent
()
!=
null
)
{
innerPanelRepainted
=
true
;
if
(!
button
.
getSize
().
equals
(
new
Dimension
(
width
,
height
)))
{
throw
new
RuntimeException
(
"Wrong size of the dirty area"
);
}
if
(!
button
.
getLocation
().
equals
(
new
Point
(
x
,
y
)))
{
throw
new
RuntimeException
(
"Wrong location of the dirty area"
);
}
}
super
.
repaint
(
tm
,
x
,
y
,
width
,
height
);
}
};
JPanel
outerPanel
=
new
JPanel
()
{
protected
boolean
isPaintingOrigin
()
{
return
isPaintingOrigin
;
}
public
void
repaint
(
long
tm
,
int
x
,
int
y
,
int
width
,
int
height
)
{
if
(
button
.
getParent
()
!=
null
)
{
outerPanelRepainted
=
true
;
if
(!
button
.
getSize
().
equals
(
new
Dimension
(
width
,
height
)))
{
throw
new
RuntimeException
(
"Wrong size of the dirty area"
);
}
}
super
.
repaint
(
tm
,
x
,
y
,
width
,
height
);
}
};
outerPanel
.
add
(
innerPanel
);
innerPanel
.
add
(
button
);
outerPanel
.
setSize
(
100
,
100
);
innerPanel
.
setBounds
(
10
,
10
,
50
,
50
);
button
.
setBounds
(
10
,
10
,
20
,
20
);
if
(
innerPanelRepainted
||
outerPanelRepainted
)
{
throw
new
RuntimeException
(
"Repainted flag is unexpectedly on"
);
}
button
.
repaint
();
if
(
innerPanelRepainted
||
outerPanelRepainted
)
{
throw
new
RuntimeException
(
"Repainted flag is unexpectedly on"
);
}
isPaintingOrigin
=
true
;
button
.
repaint
();
if
(!
innerPanelRepainted
||
!
outerPanelRepainted
)
{
throw
new
RuntimeException
(
"Repainted flag is unexpectedly off"
);
}
}
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
bug6989617
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录