Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
6ed4e837
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6ed4e837
编写于
4月 29, 2010
作者:
A
alexp
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6899413: Fix for CR #6878399 should be refactored
Reviewed-by: peterz
上级
b7f674d3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
70 addition
and
79 deletion
+70
-79
jdk/src/share/classes/javax/swing/JEditorPane.java
jdk/src/share/classes/javax/swing/JEditorPane.java
+9
-6
jdk/src/share/classes/javax/swing/JList.java
jdk/src/share/classes/javax/swing/JList.java
+7
-17
jdk/src/share/classes/javax/swing/JTable.java
jdk/src/share/classes/javax/swing/JTable.java
+12
-9
jdk/src/share/classes/javax/swing/JTextField.java
jdk/src/share/classes/javax/swing/JTextField.java
+1
-1
jdk/src/share/classes/javax/swing/JTree.java
jdk/src/share/classes/javax/swing/JTree.java
+6
-6
jdk/src/share/classes/javax/swing/SwingUtilities.java
jdk/src/share/classes/javax/swing/SwingUtilities.java
+29
-34
jdk/src/share/classes/javax/swing/text/JTextComponent.java
jdk/src/share/classes/javax/swing/text/JTextComponent.java
+6
-6
未找到文件。
jdk/src/share/classes/javax/swing/JEditorPane.java
浏览文件 @
6ed4e837
...
...
@@ -1330,8 +1330,9 @@ public class JEditorPane extends JTextComponent {
*/
public
Dimension
getPreferredSize
()
{
Dimension
d
=
super
.
getPreferredSize
();
JViewport
port
=
SwingUtilities
.
getParentViewport
(
this
);
if
(
port
!=
null
)
{
Container
parent
=
SwingUtilities
.
getUnwrappedParent
(
this
);
if
(
parent
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
parent
;
TextUI
ui
=
getUI
();
int
prefWidth
=
d
.
width
;
int
prefHeight
=
d
.
height
;
...
...
@@ -1452,8 +1453,9 @@ public class JEditorPane extends JTextComponent {
* match its own, false otherwise
*/
public
boolean
getScrollableTracksViewportWidth
()
{
JViewport
port
=
SwingUtilities
.
getParentViewport
(
this
);
if
(
port
!=
null
)
{
Container
parent
=
SwingUtilities
.
getUnwrappedParent
(
this
);
if
(
parent
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
parent
;
TextUI
ui
=
getUI
();
int
w
=
port
.
getWidth
();
Dimension
min
=
ui
.
getMinimumSize
(
this
);
...
...
@@ -1474,8 +1476,9 @@ public class JEditorPane extends JTextComponent {
* false otherwise
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities
.
getParentViewport
(
this
);
if
(
port
!=
null
)
{
Container
parent
=
SwingUtilities
.
getUnwrappedParent
(
this
);
if
(
parent
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
parent
;
TextUI
ui
=
getUI
();
int
h
=
port
.
getHeight
();
Dimension
min
=
ui
.
getMinimumSize
(
this
);
...
...
jdk/src/share/classes/javax/swing/JList.java
浏览文件 @
6ed4e837
...
...
@@ -25,17 +25,7 @@
package
javax.swing
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.Cursor
;
import
java.awt.Dimension
;
import
java.awt.Font
;
import
java.awt.FontMetrics
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.HeadlessException
;
import
java.awt.Insets
;
import
java.awt.Point
;
import
java.awt.Rectangle
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.util.Vector
;
...
...
@@ -2779,9 +2769,9 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
getVisibleRowCount
()
<=
0
)
{
return
true
;
}
JViewport
port
=
SwingUtilities
.
getParentViewpor
t
(
this
);
if
(
p
ort
!=
null
)
{
return
p
or
t
.
getWidth
()
>
getPreferredSize
().
width
;
Container
parent
=
SwingUtilities
.
getUnwrappedParen
t
(
this
);
if
(
p
arent
instanceof
JViewport
)
{
return
p
aren
t
.
getWidth
()
>
getPreferredSize
().
width
;
}
return
false
;
}
...
...
@@ -2805,9 +2795,9 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
getVisibleRowCount
()
<=
0
)
{
return
true
;
}
JViewport
port
=
SwingUtilities
.
getParentViewpor
t
(
this
);
if
(
p
ort
!=
null
)
{
return
p
or
t
.
getHeight
()
>
getPreferredSize
().
height
;
Container
parent
=
SwingUtilities
.
getUnwrappedParen
t
(
this
);
if
(
p
arent
instanceof
JViewport
)
{
return
p
aren
t
.
getHeight
()
>
getPreferredSize
().
height
;
}
return
false
;
}
...
...
jdk/src/share/classes/javax/swing/JTable.java
浏览文件 @
6ed4e837
...
...
@@ -719,8 +719,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #addNotify
*/
protected
void
configureEnclosingScrollPane
()
{
JViewport
port
=
SwingUtilities
.
getParentViewport
(
this
);
if
(
port
!=
null
)
{
Container
parent
=
SwingUtilities
.
getUnwrappedParent
(
this
);
if
(
parent
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
parent
;
Container
gp
=
port
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
...
...
@@ -752,8 +753,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* from configureEnclosingScrollPane() and updateUI() in a safe manor.
*/
private
void
configureEnclosingScrollPaneUI
()
{
JViewport
port
=
SwingUtilities
.
getParentViewport
(
this
);
if
(
port
!=
null
)
{
Container
parent
=
SwingUtilities
.
getUnwrappedParent
(
this
);
if
(
parent
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
parent
;
Container
gp
=
port
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
...
...
@@ -822,8 +824,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @since 1.3
*/
protected
void
unconfigureEnclosingScrollPane
()
{
JViewport
port
=
SwingUtilities
.
getParentViewport
(
this
);
if
(
port
!=
null
)
{
Container
parent
=
SwingUtilities
.
getUnwrappedParent
(
this
);
if
(
parent
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
parent
;
Container
gp
=
port
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
...
...
@@ -5217,10 +5220,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #getFillsViewportHeight
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities
.
getParentViewpor
t
(
this
);
Container
parent
=
SwingUtilities
.
getUnwrappedParen
t
(
this
);
return
getFillsViewportHeight
()
&&
p
ort
!=
null
&&
p
or
t
.
getHeight
()
>
getPreferredSize
().
height
;
&&
p
arent
instanceof
JViewport
&&
p
aren
t
.
getHeight
()
>
getPreferredSize
().
height
;
}
/**
...
...
jdk/src/share/classes/javax/swing/JTextField.java
浏览文件 @
6ed4e837
...
...
@@ -292,7 +292,7 @@ public class JTextField extends JTextComponent implements SwingConstants {
*/
@Override
public
boolean
isValidateRoot
()
{
return
SwingUtilities
.
getParentViewport
(
this
)
==
null
;
return
!(
SwingUtilities
.
getUnwrappedParent
(
this
)
instanceof
JViewport
)
;
}
...
...
jdk/src/share/classes/javax/swing/JTree.java
浏览文件 @
6ed4e837
...
...
@@ -3498,9 +3498,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportWidth
*/
public
boolean
getScrollableTracksViewportWidth
()
{
JViewport
port
=
SwingUtilities
.
getParentViewpor
t
(
this
);
if
(
p
ort
!=
null
)
{
return
p
or
t
.
getWidth
()
>
getPreferredSize
().
width
;
Container
parent
=
SwingUtilities
.
getUnwrappedParen
t
(
this
);
if
(
p
arent
instanceof
JViewport
)
{
return
p
aren
t
.
getWidth
()
>
getPreferredSize
().
width
;
}
return
false
;
}
...
...
@@ -3515,9 +3515,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportHeight
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities
.
getParentViewpor
t
(
this
);
if
(
p
ort
!=
null
)
{
return
p
or
t
.
getHeight
()
>
getPreferredSize
().
height
;
Container
parent
=
SwingUtilities
.
getUnwrappedParen
t
(
this
);
if
(
p
arent
instanceof
JViewport
)
{
return
p
aren
t
.
getHeight
()
>
getPreferredSize
().
height
;
}
return
false
;
}
...
...
jdk/src/share/classes/javax/swing/SwingUtilities.java
浏览文件 @
6ed4e837
...
...
@@ -1969,58 +1969,53 @@ public class SwingUtilities implements SwingConstants
}
/**
*
Looks for
the first ancestor of the {@code component}
*
Returns
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}
*
* @param component {@code Component} to get
* the first ancestor of, which is not a {@link JLayer} instance.
*
* @return the first ancestor of the {@code component}
* which is not an instance of {@link JLayer}.
* If such an ancestor can not be found, {@code null} is returned.
*
* @throws NullPointerException if {@code component} is {@code null}
* @see JLayer
*
* @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
;
public
static
Container
getUnwrappedParent
(
Component
component
)
{
Container
parent
=
component
.
getParent
();
while
(
parent
instanceof
JLayer
)
{
parent
=
parent
.
getParent
();
}
return
parent
;
}
/**
* Returns the first {@code JViewport}'s descendant
* which is not an instance of {@code JLayer} or {@code null}.
* which is not an instance of {@code JLayer}.
* If such a descendant can not be found, {@code null} is returned.
*
* 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
* this method is equivalent to {@link JViewport#getView()}
* otherwise {@link JLayer#getView()} will be recursively
* called on all descending {@code JLayer}s.
*
* @param viewport {@code JViewport} to get the first descendant of,
* which in not a {@code JLayer} instance.
*
* @return the first {@code JViewport}'s descendant
* which is not an instance of {@code JLayer} or {@code null}.
* which is not an instance of {@code JLayer}.
* If such a descendant can not be found, {@code null} is returned.
*
* @throws NullPointerException if {@code viewport} is {@code null}
* @see JViewport#getView()
* @see JLayer
*
* @since 1.7
*/
static
Component
getUnwrappedView
(
JViewport
viewport
)
{
public
static
Component
getUnwrappedView
(
JViewport
viewport
)
{
Component
view
=
viewport
.
getView
();
while
(
view
instanceof
JLayer
)
{
view
=
((
JLayer
)
view
).
getView
();
...
...
jdk/src/share/classes/javax/swing/text/JTextComponent.java
浏览文件 @
6ed4e837
...
...
@@ -2069,9 +2069,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* width to match its own
*/
public
boolean
getScrollableTracksViewportWidth
()
{
JViewport
port
=
SwingUtilities
.
getParentViewpor
t
(
this
);
if
(
p
ort
!=
null
)
{
return
p
or
t
.
getWidth
()
>
getPreferredSize
().
width
;
Container
parent
=
SwingUtilities
.
getUnwrappedParen
t
(
this
);
if
(
p
arent
instanceof
JViewport
)
{
return
p
aren
t
.
getWidth
()
>
getPreferredSize
().
width
;
}
return
false
;
}
...
...
@@ -2090,9 +2090,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* to match its own
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities
.
getParentViewpor
t
(
this
);
if
(
p
ort
!=
null
)
{
return
(
port
.
getHeight
()
>
getPreferredSize
().
height
)
;
Container
parent
=
SwingUtilities
.
getUnwrappedParen
t
(
this
);
if
(
p
arent
instanceof
JViewport
)
{
return
parent
.
getHeight
()
>
getPreferredSize
().
height
;
}
return
false
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录