Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
76121946
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看板
提交
76121946
编写于
8月 24, 2009
作者:
A
alexp
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6824395: Several Swing core components prevent using them in wrapper classes
Reviewed-by: peterz
上级
8ca994fa
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
163 addition
and
47 deletion
+163
-47
src/share/classes/javax/swing/JEditorPane.java
src/share/classes/javax/swing/JEditorPane.java
+8
-6
src/share/classes/javax/swing/JLayer.java
src/share/classes/javax/swing/JLayer.java
+0
-6
src/share/classes/javax/swing/JList.java
src/share/classes/javax/swing/JList.java
+6
-4
src/share/classes/javax/swing/JTable.java
src/share/classes/javax/swing/JTable.java
+12
-11
src/share/classes/javax/swing/JTextField.java
src/share/classes/javax/swing/JTextField.java
+3
-5
src/share/classes/javax/swing/JTree.java
src/share/classes/javax/swing/JTree.java
+6
-4
src/share/classes/javax/swing/plaf/LayerUI.java
src/share/classes/javax/swing/plaf/LayerUI.java
+0
-6
src/share/classes/javax/swing/text/JTextComponent.java
src/share/classes/javax/swing/text/JTextComponent.java
+6
-4
src/share/classes/sun/swing/SwingUtilities2.java
src/share/classes/sun/swing/SwingUtilities2.java
+18
-0
test/javax/swing/JLayer/6824395/bug6824395.java
test/javax/swing/JLayer/6824395/bug6824395.java
+80
-0
test/javax/swing/JLayer/SerializationTest/SerializationTest.java
...vax/swing/JLayer/SerializationTest/SerializationTest.java
+24
-1
未找到文件。
src/share/classes/javax/swing/JEditorPane.java
浏览文件 @
76121946
...
@@ -24,6 +24,8 @@
...
@@ -24,6 +24,8 @@
*/
*/
package
javax.swing
;
package
javax.swing
;
import
sun.swing.SwingUtilities2
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.event.*
;
import
java.lang.reflect.*
;
import
java.lang.reflect.*
;
...
@@ -1323,8 +1325,8 @@ public class JEditorPane extends JTextComponent {
...
@@ -1323,8 +1325,8 @@ public class JEditorPane extends JTextComponent {
*/
*/
public
Dimension
getPreferredSize
()
{
public
Dimension
getPreferredSize
()
{
Dimension
d
=
super
.
getPreferredSize
();
Dimension
d
=
super
.
getPreferredSize
();
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
JViewport
port
=
(
JViewport
)
getParent
();
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
TextUI
ui
=
getUI
();
int
prefWidth
=
d
.
width
;
int
prefWidth
=
d
.
width
;
int
prefHeight
=
d
.
height
;
int
prefHeight
=
d
.
height
;
...
@@ -1445,8 +1447,8 @@ public class JEditorPane extends JTextComponent {
...
@@ -1445,8 +1447,8 @@ public class JEditorPane extends JTextComponent {
* match its own, false otherwise
* match its own, false otherwise
*/
*/
public
boolean
getScrollableTracksViewportWidth
()
{
public
boolean
getScrollableTracksViewportWidth
()
{
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
JViewport
port
=
(
JViewport
)
getParent
();
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
TextUI
ui
=
getUI
();
int
w
=
port
.
getWidth
();
int
w
=
port
.
getWidth
();
Dimension
min
=
ui
.
getMinimumSize
(
this
);
Dimension
min
=
ui
.
getMinimumSize
(
this
);
...
@@ -1467,8 +1469,8 @@ public class JEditorPane extends JTextComponent {
...
@@ -1467,8 +1469,8 @@ public class JEditorPane extends JTextComponent {
* false otherwise
* false otherwise
*/
*/
public
boolean
getScrollableTracksViewportHeight
()
{
public
boolean
getScrollableTracksViewportHeight
()
{
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
JViewport
port
=
(
JViewport
)
getParent
();
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
TextUI
ui
=
getUI
();
int
h
=
port
.
getHeight
();
int
h
=
port
.
getHeight
();
Dimension
min
=
ui
.
getMinimumSize
(
this
);
Dimension
min
=
ui
.
getMinimumSize
(
this
);
...
...
src/share/classes/javax/swing/JLayer.java
浏览文件 @
76121946
...
@@ -495,9 +495,6 @@ public final class JLayer<V extends Component>
...
@@ -495,9 +495,6 @@ public final class JLayer<V extends Component>
if
(
getUI
()
!=
null
)
{
if
(
getUI
()
!=
null
)
{
return
getUI
().
getScrollableTracksViewportHeight
(
this
);
return
getUI
().
getScrollableTracksViewportHeight
(
this
);
}
}
if
(
getParent
()
instanceof
JViewport
)
{
return
((
getParent
()).
getHeight
()
>
getPreferredSize
().
height
);
}
return
false
;
return
false
;
}
}
...
@@ -518,9 +515,6 @@ public final class JLayer<V extends Component>
...
@@ -518,9 +515,6 @@ public final class JLayer<V extends Component>
if
(
getUI
()
!=
null
)
{
if
(
getUI
()
!=
null
)
{
return
getUI
().
getScrollableTracksViewportWidth
(
this
);
return
getUI
().
getScrollableTracksViewportWidth
(
this
);
}
}
if
(
getParent
()
instanceof
JViewport
)
{
return
((
getParent
()).
getWidth
()
>
getPreferredSize
().
width
);
}
return
false
;
return
false
;
}
}
...
...
src/share/classes/javax/swing/JList.java
浏览文件 @
76121946
...
@@ -2722,8 +2722,9 @@ public class JList extends JComponent implements Scrollable, Accessible
...
@@ -2722,8 +2722,9 @@ public class JList extends JComponent implements Scrollable, Accessible
getVisibleRowCount
()
<=
0
)
{
getVisibleRowCount
()
<=
0
)
{
return
true
;
return
true
;
}
}
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
return
(
getParent
().
getWidth
()
>
getPreferredSize
().
width
);
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
}
return
false
;
return
false
;
}
}
...
@@ -2747,8 +2748,9 @@ public class JList extends JComponent implements Scrollable, Accessible
...
@@ -2747,8 +2748,9 @@ public class JList extends JComponent implements Scrollable, Accessible
getVisibleRowCount
()
<=
0
)
{
getVisibleRowCount
()
<=
0
)
{
return
true
;
return
true
;
}
}
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
return
(
getParent
().
getHeight
()
>
getPreferredSize
().
height
);
if
(
port
!=
null
)
{
return
port
.
getHeight
()
>
getPreferredSize
().
height
;
}
}
return
false
;
return
false
;
}
}
...
...
src/share/classes/javax/swing/JTable.java
浏览文件 @
76121946
...
@@ -718,9 +718,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
...
@@ -718,9 +718,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #addNotify
* @see #addNotify
*/
*/
protected
void
configureEnclosingScrollPane
()
{
protected
void
configureEnclosingScrollPane
()
{
Container
p
=
getParent
(
);
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
p
instanceof
JViewport
)
{
if
(
p
ort
!=
null
)
{
Container
gp
=
p
.
getParent
();
Container
gp
=
p
ort
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
// Make certain we are the viewPort's view and not, for
// Make certain we are the viewPort's view and not, for
...
@@ -750,9 +750,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
...
@@ -750,9 +750,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* from configureEnclosingScrollPane() and updateUI() in a safe manor.
* from configureEnclosingScrollPane() and updateUI() in a safe manor.
*/
*/
private
void
configureEnclosingScrollPaneUI
()
{
private
void
configureEnclosingScrollPaneUI
()
{
Container
p
=
getParent
(
);
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
p
instanceof
JViewport
)
{
if
(
p
ort
!=
null
)
{
Container
gp
=
p
.
getParent
();
Container
gp
=
p
ort
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
// Make certain we are the viewPort's view and not, for
// Make certain we are the viewPort's view and not, for
...
@@ -819,9 +819,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
...
@@ -819,9 +819,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @since 1.3
* @since 1.3
*/
*/
protected
void
unconfigureEnclosingScrollPane
()
{
protected
void
unconfigureEnclosingScrollPane
()
{
Container
p
=
getParent
(
);
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
p
instanceof
JViewport
)
{
if
(
p
ort
!=
null
)
{
Container
gp
=
p
.
getParent
();
Container
gp
=
p
ort
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
// Make certain we are the viewPort's view and not, for
// Make certain we are the viewPort's view and not, for
...
@@ -5215,9 +5215,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
...
@@ -5215,9 +5215,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #getFillsViewportHeight
* @see #getFillsViewportHeight
*/
*/
public
boolean
getScrollableTracksViewportHeight
()
{
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
return
getFillsViewportHeight
()
return
getFillsViewportHeight
()
&&
getParent
()
instanceof
JViewport
&&
port
!=
null
&&
(
getParent
().
getHeight
()
>
getPreferredSize
().
height
)
;
&&
port
.
getHeight
()
>
getPreferredSize
().
height
;
}
}
/**
/**
...
...
src/share/classes/javax/swing/JTextField.java
浏览文件 @
76121946
...
@@ -24,6 +24,8 @@
...
@@ -24,6 +24,8 @@
*/
*/
package
javax.swing
;
package
javax.swing
;
import
sun.swing.SwingUtilities2
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.event.*
;
import
java.beans.*
;
import
java.beans.*
;
...
@@ -288,11 +290,7 @@ public class JTextField extends JTextComponent implements SwingConstants {
...
@@ -288,11 +290,7 @@ public class JTextField extends JTextComponent implements SwingConstants {
* @see JComponent#isValidateRoot
* @see JComponent#isValidateRoot
*/
*/
public
boolean
isValidateRoot
()
{
public
boolean
isValidateRoot
()
{
Component
parent
=
getParent
();
return
SwingUtilities2
.
getViewport
(
this
)
==
null
;
if
(
parent
instanceof
JViewport
)
{
return
false
;
}
return
true
;
}
}
...
...
src/share/classes/javax/swing/JTree.java
浏览文件 @
76121946
...
@@ -3498,8 +3498,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
...
@@ -3498,8 +3498,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportWidth
* @see Scrollable#getScrollableTracksViewportWidth
*/
*/
public
boolean
getScrollableTracksViewportWidth
()
{
public
boolean
getScrollableTracksViewportWidth
()
{
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
return
getParent
().
getWidth
()
>
getPreferredSize
().
width
;
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
}
return
false
;
return
false
;
}
}
...
@@ -3514,8 +3515,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
...
@@ -3514,8 +3515,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportHeight
* @see Scrollable#getScrollableTracksViewportHeight
*/
*/
public
boolean
getScrollableTracksViewportHeight
()
{
public
boolean
getScrollableTracksViewportHeight
()
{
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
return
getParent
().
getHeight
()
>
getPreferredSize
().
height
;
if
(
port
!=
null
)
{
return
port
.
getHeight
()
>
getPreferredSize
().
height
;
}
}
return
false
;
return
false
;
}
}
...
...
src/share/classes/javax/swing/plaf/LayerUI.java
浏览文件 @
76121946
...
@@ -303,9 +303,6 @@ public class LayerUI<V extends Component>
...
@@ -303,9 +303,6 @@ public class LayerUI<V extends Component>
if
(
l
.
getView
()
instanceof
Scrollable
)
{
if
(
l
.
getView
()
instanceof
Scrollable
)
{
return
((
Scrollable
)
l
.
getView
()).
getScrollableTracksViewportHeight
();
return
((
Scrollable
)
l
.
getView
()).
getScrollableTracksViewportHeight
();
}
}
if
(
l
.
getParent
()
instanceof
JViewport
)
{
return
(((
JViewport
)
l
.
getParent
()).
getHeight
()
>
l
.
getPreferredSize
().
height
);
}
return
false
;
return
false
;
}
}
...
@@ -322,9 +319,6 @@ public class LayerUI<V extends Component>
...
@@ -322,9 +319,6 @@ public class LayerUI<V extends Component>
if
(
l
.
getView
()
instanceof
Scrollable
)
{
if
(
l
.
getView
()
instanceof
Scrollable
)
{
return
((
Scrollable
)
l
.
getView
()).
getScrollableTracksViewportWidth
();
return
((
Scrollable
)
l
.
getView
()).
getScrollableTracksViewportWidth
();
}
}
if
(
l
.
getParent
()
instanceof
JViewport
)
{
return
(((
JViewport
)
l
.
getParent
()).
getWidth
()
>
l
.
getPreferredSize
().
width
);
}
return
false
;
return
false
;
}
}
...
...
src/share/classes/javax/swing/text/JTextComponent.java
浏览文件 @
76121946
...
@@ -2069,8 +2069,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
...
@@ -2069,8 +2069,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* width to match its own
* width to match its own
*/
*/
public
boolean
getScrollableTracksViewportWidth
()
{
public
boolean
getScrollableTracksViewportWidth
()
{
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
return
(
getParent
().
getWidth
()
>
getPreferredSize
().
width
);
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
}
return
false
;
return
false
;
}
}
...
@@ -2089,8 +2090,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
...
@@ -2089,8 +2090,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* to match its own
* to match its own
*/
*/
public
boolean
getScrollableTracksViewportHeight
()
{
public
boolean
getScrollableTracksViewportHeight
()
{
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
return
(
getParent
().
getHeight
()
>
getPreferredSize
().
height
);
if
(
port
!=
null
)
{
return
(
port
.
getHeight
()
>
getPreferredSize
().
height
);
}
}
return
false
;
return
false
;
}
}
...
...
src/share/classes/sun/swing/SwingUtilities2.java
浏览文件 @
76121946
...
@@ -1844,4 +1844,22 @@ public class SwingUtilities2 {
...
@@ -1844,4 +1844,22 @@ public class SwingUtilities2 {
boolean
three
)
{
boolean
three
)
{
return
liesIn
(
rect
,
p
,
false
,
false
,
three
);
return
liesIn
(
rect
,
p
,
false
,
false
,
three
);
}
}
/**
* Returns the {@code JViewport} instance for the {@code component}
* or {@code null}.
*
* @return the {@code JViewport} instance for the {@code component}
* or {@code null}
* @throws NullPointerException if {@code component} is {@code null}
*/
public
static
JViewport
getViewport
(
Component
component
)
{
do
{
component
=
component
.
getParent
();
if
(
component
instanceof
JViewport
)
{
return
(
JViewport
)
component
;
}
}
while
(
component
instanceof
JLayer
);
return
null
;
}
}
}
test/javax/swing/JLayer/6824395/bug6824395.java
0 → 100644
浏览文件 @
76121946
/*
* Copyright 2009 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @summary Checks that JLayer inside JViewport works is correctly laid out
* @author Alexander Potochkin
* @run main bug6824395
*/
import
sun.awt.SunToolkit
;
import
javax.swing.*
;
import
javax.swing.plaf.LayerUI
;
import
java.awt.*
;
public
class
bug6824395
{
static
JScrollPane
scrollPane
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
JFrame
frame
=
new
JFrame
(
"testing"
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
JEditorPane
editorPane
=
new
JEditorPane
();
String
str
=
"hello\n"
;
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
str
+=
str
;
}
editorPane
.
setText
(
str
);
JLayer
<
JEditorPane
>
editorPaneLayer
=
new
JLayer
<
JEditorPane
>(
editorPane
);
LayerUI
<
JComponent
>
layerUI
=
new
LayerUI
<
JComponent
>();
editorPaneLayer
.
setUI
(
layerUI
);
scrollPane
=
new
JScrollPane
(
editorPaneLayer
);
scrollPane
.
setPreferredSize
(
new
Dimension
(
200
,
250
));
frame
.
add
(
scrollPane
);
frame
.
setSize
(
200
,
200
);
frame
.
pack
();
frame
.
setVisible
(
true
);
}
});
toolkit
.
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
if
(
scrollPane
.
getViewportBorderBounds
().
width
!=
scrollPane
.
getViewport
().
getView
().
getWidth
())
{
throw
new
RuntimeException
(
"Wrong component's width!"
);
}
}
});
}
}
test/javax/swing/JLayer/SerializationTest/SerializationTest.java
浏览文件 @
76121946
/*
* Copyright 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
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
/*
* @test
* @test
* @summary Makes sure that JLayer is synchronizable
* @summary Makes sure that JLayer is synchronizable
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录