Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6b8ffb4b
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看板
提交
6b8ffb4b
编写于
2月 10, 2011
作者:
A
alexp
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6993171: JavaTest/JDK7b114 - no help text is shown for interview questions, JavaTest HANGS UP
Reviewed-by: rupashka
上级
2c8871ff
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
148 addition
and
91 deletion
+148
-91
src/share/classes/javax/swing/JComponent.java
src/share/classes/javax/swing/JComponent.java
+20
-4
src/share/classes/javax/swing/JLayer.java
src/share/classes/javax/swing/JLayer.java
+25
-13
src/share/classes/javax/swing/RepaintManager.java
src/share/classes/javax/swing/RepaintManager.java
+0
-11
src/share/classes/javax/swing/SwingUtilities.java
src/share/classes/javax/swing/SwingUtilities.java
+11
-0
src/share/classes/javax/swing/plaf/LayerUI.java
src/share/classes/javax/swing/plaf/LayerUI.java
+10
-12
test/javax/swing/JComponent/6989617/bug6989617.java
test/javax/swing/JComponent/6989617/bug6989617.java
+82
-51
未找到文件。
src/share/classes/javax/swing/JComponent.java
浏览文件 @
6b8ffb4b
...
...
@@ -4910,14 +4910,17 @@ public abstract class JComponent extends Container implements Serializable,
* 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.
* Calling {@link #repaint} or {@link #paintImmediately(int, int, int, int)}
* on a Swing component will result in calling
* the {@link JComponent#paintImmediately(int, int, int, int)} method of
* the first ancestor which {@code isPaintingOrigin()} returns {@true}, if there are any.
* <p/>
* {@code JComponent} subclasses that need to be
re
painted when any of their
* {@code JComponent} subclasses that need to be painted when any of their
* children are repainted should override this method to return {@code true}.
*
* @return always returns {@code false}
*
* @see #paintImmediately(int, int, int, int)
*/
protected
boolean
isPaintingOrigin
()
{
return
false
;
...
...
@@ -4932,12 +4935,16 @@ public abstract class JComponent extends Container implements Serializable,
* and can collapse redundant requests into a single paint call.
* This method is useful if one needs to update the display while
* the current event is being dispatched.
* <p>
* This method is to be overridden when the dirty region needs to be changed
* for components that are painting origins.
*
* @param x the x value of the region to be painted
* @param y the y value of the region to be painted
* @param w the width of the region to be painted
* @param h the height of the region to be painted
* @see #repaint
* @see #isPaintingOrigin()
*/
public
void
paintImmediately
(
int
x
,
int
y
,
int
w
,
int
h
)
{
Component
c
=
this
;
...
...
@@ -4946,6 +4953,15 @@ public abstract class JComponent extends Container implements Serializable,
if
(!
isShowing
())
{
return
;
}
JComponent
paintingOigin
=
SwingUtilities
.
getPaintingOrigin
(
this
);
if
(
paintingOigin
!=
null
)
{
Rectangle
rectangle
=
SwingUtilities
.
convertRectangle
(
c
,
new
Rectangle
(
x
,
y
,
w
,
h
),
paintingOigin
);
paintingOigin
.
paintImmediately
(
rectangle
.
x
,
rectangle
.
y
,
rectangle
.
width
,
rectangle
.
height
);
return
;
}
while
(!
c
.
isOpaque
())
{
parent
=
c
.
getParent
();
if
(
parent
!=
null
)
{
...
...
src/share/classes/javax/swing/JLayer.java
浏览文件 @
6b8ffb4b
...
...
@@ -156,8 +156,9 @@ public final class JLayer<V extends Component>
// when layerUI is serializable
private
LayerUI
<?
super
V
>
layerUI
;
private
JPanel
glassPane
;
private
boolean
isPainting
;
private
long
eventMask
;
private
transient
boolean
isPainting
;
private
transient
boolean
isPaintingImmediately
;
private
static
final
LayerEventController
eventController
=
new
LayerEventController
();
...
...
@@ -393,17 +394,25 @@ public final class JLayer<V extends Component>
}
/**
* Delegates repainting to {@link javax.swing.plaf.LayerUI#repaint} method.
* Delegates its functionality to the
* {@link javax.swing.plaf.LayerUI#paintImmediately(int, int, int, int, JLayer)} method,
* if {@code LayerUI} is set.
*
* @param tm this parameter is not used
* @param x the x value of the dirty region
* @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
*/
public
void
repaint
(
long
tm
,
int
x
,
int
y
,
int
width
,
int
height
)
{
if
(
getUI
()
!=
null
)
{
getUI
().
repaint
(
tm
,
x
,
y
,
width
,
height
,
this
);
* @param x the x value of the region to be painted
* @param y the y value of the region to be painted
* @param w the width of the region to be painted
* @param h the height of the region to be painted
*/
public
void
paintImmediately
(
int
x
,
int
y
,
int
w
,
int
h
)
{
if
(!
isPaintingImmediately
&&
getUI
()
!=
null
)
{
isPaintingImmediately
=
true
;
try
{
getUI
().
paintImmediately
(
x
,
y
,
w
,
h
,
this
);
}
finally
{
isPaintingImmediately
=
false
;
}
}
else
{
super
.
paintImmediately
(
x
,
y
,
w
,
h
);
}
}
...
...
@@ -415,8 +424,11 @@ public final class JLayer<V extends Component>
public
void
paint
(
Graphics
g
)
{
if
(!
isPainting
)
{
isPainting
=
true
;
super
.
paintComponent
(
g
);
isPainting
=
false
;
try
{
super
.
paintComponent
(
g
);
}
finally
{
isPainting
=
false
;
}
}
else
{
super
.
paint
(
g
);
}
...
...
src/share/classes/javax/swing/RepaintManager.java
浏览文件 @
6b8ffb4b
...
...
@@ -438,7 +438,6 @@ 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
)
...
...
@@ -448,16 +447,6 @@ 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
);
}
...
...
src/share/classes/javax/swing/SwingUtilities.java
浏览文件 @
6b8ffb4b
...
...
@@ -1532,6 +1532,17 @@ public class SwingUtilities implements SwingConstants
return
applet
;
}
static
JComponent
getPaintingOrigin
(
JComponent
c
)
{
Container
p
=
c
;
while
((
p
=
p
.
getParent
())
instanceof
JComponent
)
{
JComponent
jp
=
(
JComponent
)
p
;
if
(
jp
.
isPaintingOrigin
())
{
return
jp
;
}
}
return
null
;
}
/**
* Process the key bindings for the <code>Component</code> associated with
* <code>event</code>. This method is only useful if
...
...
src/share/classes/javax/swing/plaf/LayerUI.java
浏览文件 @
6b8ffb4b
...
...
@@ -703,21 +703,19 @@ public class LayerUI<V extends Component>
}
/**
* Adds the specified region to the dirty region list if the component
* is showing. The component will be repainted after all of the
* currently pending events have been dispatched.
* Paints the specified region in the {@code JLayer} this {@code LayerUI} is set to, immediately.
* <p/>
* This method is to be overridden when the dirty region needs to be changed.
* The default implementation delegates its functionality to {@link JComponent#paintImmediately(int, int, int, int)}.
*
* @param tm this parameter is not used
* @param x the x value of the dirty region
* @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 java.awt.Component#isShowing
* @see RepaintManager#addDirtyRegion
* @param x the x value of the region to be painted
* @param y the y value of the region to be painted
* @param w the width of the region to be painted
* @param h the height of the region to be painted
*
* @see JComponent#paintImmediately(int, int, int, int)
*/
public
void
repaint
(
long
tm
,
int
x
,
int
y
,
int
width
,
int
height
,
JLayer
<?
extends
V
>
l
)
{
RepaintManager
.
currentManager
(
l
).
addDirtyRegion
(
l
,
x
,
y
,
width
,
height
);
public
void
paintImmediately
(
int
x
,
int
y
,
int
width
,
int
height
,
JLayer
<?
extends
V
>
l
)
{
l
.
paintImmediately
(
x
,
y
,
width
,
height
);
}
}
test/javax/swing/JComponent/6989617/bug6989617.java
浏览文件 @
6b8ffb4b
/*
* Copyright (c) 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 201
1
, 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
...
...
@@ -28,76 +28,107 @@
@run main bug6989617
*/
import
sun.awt.SunToolkit
;
import
javax.swing.*
;
import
java.awt.*
;
public
class
bug6989617
{
private
static
MyPanel
panel
;
private
static
JButton
button
;
private
boolean
isPaintingOrigin
;
private
boolean
innerPanelRepainted
,
outerPanelRepainted
;
public
bug6989617
()
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
JFrame
frame
=
new
JFrame
();
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
panel
=
new
MyPanel
();
final
JButton
button
=
new
JButton
(
"button"
);
button
=
new
JButton
(
"Hello"
);
panel
.
add
(
button
);
frame
.
add
(
panel
);
JPanel
innerPanel
=
new
JPanel
()
{
protected
boolean
isPaintingOrigin
()
{
return
isPaintingOrigin
;
frame
.
setSize
(
200
,
300
);
frame
.
setVisible
(
true
);
}
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"
);
}
});
// Testing the panel as a painting origin,
// the panel.paintImmediately() must be triggered
// when button.repaint() is called
toolkit
.
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
if
(
panel
.
getPaintRectangle
()
!=
null
)
{
throw
new
RuntimeException
(
"paint rectangle is not null"
);
}
super
.
repaint
(
tm
,
x
,
y
,
width
,
height
);
button
.
repaint
(
);
}
};
JPanel
outerPanel
=
new
JPanel
()
{
protected
boolean
isPaintingOrigin
()
{
return
isPaintingOrigin
;
});
toolkit
.
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
Rectangle
pr
=
panel
.
getPaintRectangle
();
if
(!
pr
.
getSize
().
equals
(
button
.
getSize
()))
{
throw
new
RuntimeException
(
"wrong size of the dirty area"
);
}
if
(!
pr
.
getLocation
().
equals
(
button
.
getLocation
()))
{
throw
new
RuntimeException
(
"wrong location of the dirty area"
);
}
}
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"
);
}
});
// Testing the panel as NOT a painting origin
// the panel.paintImmediately() must NOT be triggered
// when button.repaint() is called
toolkit
.
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
panel
.
resetPaintRectangle
();
panel
.
setPaintingOrigin
(
false
);
if
(
panel
.
getPaintRectangle
()
!=
null
)
{
throw
new
RuntimeException
(
"paint rectangle is not null"
);
}
button
.
repaint
();
}
});
toolkit
.
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
if
(
panel
.
getPaintRectangle
()
!=
null
)
{
throw
new
RuntimeException
(
"paint rectangle is not null"
);
}
super
.
repaint
(
tm
,
x
,
y
,
width
,
height
);
System
.
out
.
println
(
"Test passed..."
);
}
};
});
}
static
class
MyPanel
extends
JPanel
{
private
boolean
isPaintingOrigin
=
true
;
private
Rectangle
paintRectangle
;
outerPanel
.
add
(
innerPanel
);
innerPanel
.
add
(
button
);
{
setLayout
(
new
GridBagLayout
());
}
outerPanel
.
setSize
(
100
,
100
);
innerPanel
.
setBounds
(
10
,
10
,
50
,
50
)
;
button
.
setBounds
(
10
,
10
,
20
,
20
);
public
boolean
isPaintingOrigin
()
{
return
isPaintingOrigin
;
}
if
(
innerPanelRepainted
||
outerPanelRepainted
)
{
throw
new
RuntimeException
(
"Repainted flag is unexpectedly on"
)
;
public
void
setPaintingOrigin
(
boolean
paintingOrigin
)
{
isPaintingOrigin
=
paintingOrigin
;
}
button
.
repaint
();
if
(
innerPanelRepainted
||
outerPanelRepainted
)
{
throw
new
RuntimeException
(
"Repainted flag is unexpectedly on"
);
public
void
paintImmediately
(
int
x
,
int
y
,
int
w
,
int
h
)
{
super
.
paintImmediately
(
x
,
y
,
w
,
h
);
paintRectangle
=
new
Rectangle
(
x
,
y
,
w
,
h
);
}
isPaintingOrigin
=
true
;
button
.
repaint
();
if
(!
innerPanelRepainted
||
!
outerPanelRepainted
)
{
throw
new
RuntimeException
(
"Repainted flag is unexpectedly off"
);
public
Rectangle
getPaintRectangle
()
{
return
paintRectangle
==
null
?
null
:
new
Rectangle
(
paintRectangle
);
}
}
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
bug6989617
();
public
void
resetPaintRectangle
()
{
this
.
paintRectangle
=
null
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录