Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e297478c
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看板
提交
e297478c
编写于
11月 06, 2009
作者:
A
alexp
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6878399: public SwingUtilities.getParentViewport() is required
Reviewed-by: peterz
上级
9ddae00e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
80 addition
and
35 deletion
+80
-35
src/share/classes/javax/swing/JEditorPane.java
src/share/classes/javax/swing/JEditorPane.java
+3
-3
src/share/classes/javax/swing/JList.java
src/share/classes/javax/swing/JList.java
+2
-2
src/share/classes/javax/swing/JTable.java
src/share/classes/javax/swing/JTable.java
+10
-7
src/share/classes/javax/swing/JTextField.java
src/share/classes/javax/swing/JTextField.java
+1
-1
src/share/classes/javax/swing/JTree.java
src/share/classes/javax/swing/JTree.java
+2
-2
src/share/classes/javax/swing/SwingUtilities.java
src/share/classes/javax/swing/SwingUtilities.java
+60
-0
src/share/classes/javax/swing/text/JTextComponent.java
src/share/classes/javax/swing/text/JTextComponent.java
+2
-2
src/share/classes/sun/swing/SwingUtilities2.java
src/share/classes/sun/swing/SwingUtilities2.java
+0
-18
未找到文件。
src/share/classes/javax/swing/JEditorPane.java
浏览文件 @
e297478c
...
...
@@ -1330,7 +1330,7 @@ public class JEditorPane extends JTextComponent {
*/
public
Dimension
getPreferredSize
()
{
Dimension
d
=
super
.
getPreferredSize
();
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
int
prefWidth
=
d
.
width
;
...
...
@@ -1452,7 +1452,7 @@ public class JEditorPane extends JTextComponent {
* match its own, false otherwise
*/
public
boolean
getScrollableTracksViewportWidth
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
int
w
=
port
.
getWidth
();
...
...
@@ -1474,7 +1474,7 @@ public class JEditorPane extends JTextComponent {
* false otherwise
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
int
h
=
port
.
getHeight
();
...
...
src/share/classes/javax/swing/JList.java
浏览文件 @
e297478c
...
...
@@ -2722,7 +2722,7 @@ public class JList extends JComponent implements Scrollable, Accessible
getVisibleRowCount
()
<=
0
)
{
return
true
;
}
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
...
...
@@ -2748,7 +2748,7 @@ public class JList extends JComponent implements Scrollable, Accessible
getVisibleRowCount
()
<=
0
)
{
return
true
;
}
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getHeight
()
>
getPreferredSize
().
height
;
}
...
...
src/share/classes/javax/swing/JTable.java
浏览文件 @
e297478c
...
...
@@ -719,7 +719,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #addNotify
*/
protected
void
configureEnclosingScrollPane
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
Container
gp
=
port
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
...
...
@@ -728,7 +728,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
// example, the rowHeaderView of the scrollPane -
// an implementor of fixed columns might do this.
JViewport
viewport
=
scrollPane
.
getViewport
();
if
(
viewport
==
null
||
viewport
.
getView
()
!=
this
)
{
if
(
viewport
==
null
||
SwingUtilities
.
getUnwrappedView
(
viewport
)
!=
this
)
{
return
;
}
scrollPane
.
setColumnHeaderView
(
getTableHeader
());
...
...
@@ -751,7 +752,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* from configureEnclosingScrollPane() and updateUI() in a safe manor.
*/
private
void
configureEnclosingScrollPaneUI
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
Container
gp
=
port
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
...
...
@@ -760,7 +761,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
// example, the rowHeaderView of the scrollPane -
// an implementor of fixed columns might do this.
JViewport
viewport
=
scrollPane
.
getViewport
();
if
(
viewport
==
null
||
viewport
.
getView
()
!=
this
)
{
if
(
viewport
==
null
||
SwingUtilities
.
getUnwrappedView
(
viewport
)
!=
this
)
{
return
;
}
// scrollPane.getViewport().setBackingStoreEnabled(true);
...
...
@@ -820,7 +822,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @since 1.3
*/
protected
void
unconfigureEnclosingScrollPane
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
Container
gp
=
port
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
...
...
@@ -829,7 +831,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
// example, the rowHeaderView of the scrollPane -
// an implementor of fixed columns might do this.
JViewport
viewport
=
scrollPane
.
getViewport
();
if
(
viewport
==
null
||
viewport
.
getView
()
!=
this
)
{
if
(
viewport
==
null
||
SwingUtilities
.
getUnwrappedView
(
viewport
)
!=
this
)
{
return
;
}
scrollPane
.
setColumnHeaderView
(
null
);
...
...
@@ -5216,7 +5219,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #getFillsViewportHeight
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
return
getFillsViewportHeight
()
&&
port
!=
null
&&
port
.
getHeight
()
>
getPreferredSize
().
height
;
...
...
src/share/classes/javax/swing/JTextField.java
浏览文件 @
e297478c
...
...
@@ -290,7 +290,7 @@ public class JTextField extends JTextComponent implements SwingConstants {
* @see JComponent#isValidateRoot
*/
public
boolean
isValidateRoot
()
{
return
SwingUtilities
2
.
ge
tViewport
(
this
)
==
null
;
return
SwingUtilities
.
getParen
tViewport
(
this
)
==
null
;
}
...
...
src/share/classes/javax/swing/JTree.java
浏览文件 @
e297478c
...
...
@@ -3498,7 +3498,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportWidth
*/
public
boolean
getScrollableTracksViewportWidth
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
...
...
@@ -3515,7 +3515,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportHeight
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getHeight
()
>
getPreferredSize
().
height
;
}
...
...
src/share/classes/javax/swing/SwingUtilities.java
浏览文件 @
e297478c
...
...
@@ -1967,4 +1967,64 @@ public class SwingUtilities implements SwingConstants
SwingUtilities
.
updateComponentTreeUI
(
component
);
}
}
/**
* Looks for the first ancestor of the {@code component}
* which is not an instance of {@link JLayer}.
* If this ancestor is an instance of {@code JViewport},
* this {@code JViewport} is returned, otherwise returns {@code null}.
* The following way of obtaining the parent {@code JViewport}
* is not recommended any more:
* <pre>
* JViewport port = null;
* Container parent = component.getParent();
* // not recommended any more
* if(parent instanceof JViewport) {
* port = (JViewport) parent;
* }
* </pre>
* Here is the way to go:
* <pre>
* // the correct way:
* JViewport port = SwingUtilities.getParentViewport(component);
* </pre>
* @param component {@code Component} to get the parent {@code JViewport} of.
* @return the {@code JViewport} instance for the {@code component}
* or {@code null}
* @throws NullPointerException if {@code component} is {@code null}
*
* @since 1.7
*/
public
static
JViewport
getParentViewport
(
Component
component
)
{
do
{
component
=
component
.
getParent
();
if
(
component
instanceof
JViewport
)
{
return
(
JViewport
)
component
;
}
}
while
(
component
instanceof
JLayer
);
return
null
;
}
/**
* Returns the first {@code JViewport}'s descendant
* which is not an instance of {@code JLayer} or {@code null}.
*
* If the {@code viewport}'s view component is not a {@code JLayer},
* this method is equal to {@link JViewport#getView()}
* otherwise {@link JLayer#getView()} will be recursively tested
*
* @return the first {@code JViewport}'s descendant
* which is not an instance of {@code JLayer} or {@code null}.
*
* @throws NullPointerException if {@code viewport} is {@code null}
* @see JViewport#getView()
* @see JLayer
*/
static
Component
getUnwrappedView
(
JViewport
viewport
)
{
Component
view
=
viewport
.
getView
();
while
(
view
instanceof
JLayer
)
{
view
=
((
JLayer
)
view
).
getView
();
}
return
view
;
}
}
src/share/classes/javax/swing/text/JTextComponent.java
浏览文件 @
e297478c
...
...
@@ -2069,7 +2069,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* width to match its own
*/
public
boolean
getScrollableTracksViewportWidth
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
...
...
@@ -2090,7 +2090,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* to match its own
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities
2
.
ge
tViewport
(
this
);
JViewport
port
=
SwingUtilities
.
getParen
tViewport
(
this
);
if
(
port
!=
null
)
{
return
(
port
.
getHeight
()
>
getPreferredSize
().
height
);
}
...
...
src/share/classes/sun/swing/SwingUtilities2.java
浏览文件 @
e297478c
...
...
@@ -1807,22 +1807,4 @@ public class SwingUtilities2 {
boolean
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
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录