Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
884e1998
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看板
提交
884e1998
编写于
7月 22, 2013
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8015926: NPE when using SynthTreeUI's expandPath()
Reviewed-by: alexsch
上级
09dacb64
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
102 addition
and
4 deletion
+102
-4
src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
+4
-4
test/javax/swing/plaf/synth/Test8015926.java
test/javax/swing/plaf/synth/Test8015926.java
+98
-0
未找到文件。
src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
浏览文件 @
884e1998
...
@@ -344,7 +344,8 @@ public class SynthTreeUI extends BasicTreeUI
...
@@ -344,7 +344,8 @@ public class SynthTreeUI extends BasicTreeUI
configureRenderer
(
cellContext
);
configureRenderer
(
cellContext
);
while
(!
done
&&
paintingEnumerator
.
hasMoreElements
())
{
while
(!
done
&&
paintingEnumerator
.
hasMoreElements
())
{
path
=
(
TreePath
)
paintingEnumerator
.
nextElement
();
path
=
(
TreePath
)
paintingEnumerator
.
nextElement
();
if
(
path
!=
null
)
{
bounds
=
getPathBounds
(
tree
,
path
);
if
((
path
!=
null
)
&&
(
bounds
!=
null
))
{
isLeaf
=
treeModel
.
isLeaf
(
path
.
getLastPathComponent
());
isLeaf
=
treeModel
.
isLeaf
(
path
.
getLastPathComponent
());
if
(
isLeaf
)
{
if
(
isLeaf
)
{
isExpanded
=
hasBeenExpanded
=
false
;
isExpanded
=
hasBeenExpanded
=
false
;
...
@@ -353,7 +354,6 @@ public class SynthTreeUI extends BasicTreeUI
...
@@ -353,7 +354,6 @@ public class SynthTreeUI extends BasicTreeUI
isExpanded
=
treeState
.
getExpandedState
(
path
);
isExpanded
=
treeState
.
getExpandedState
(
path
);
hasBeenExpanded
=
tree
.
hasBeenExpanded
(
path
);
hasBeenExpanded
=
tree
.
hasBeenExpanded
(
path
);
}
}
bounds
=
getPathBounds
(
tree
,
path
);
rowBounds
.
y
=
bounds
.
y
;
rowBounds
.
y
=
bounds
.
y
;
rowBounds
.
height
=
bounds
.
height
;
rowBounds
.
height
=
bounds
.
height
;
paintRow
(
renderer
,
dtcr
,
context
,
cellContext
,
g
,
paintRow
(
renderer
,
dtcr
,
context
,
cellContext
,
g
,
...
@@ -383,7 +383,8 @@ public class SynthTreeUI extends BasicTreeUI
...
@@ -383,7 +383,8 @@ public class SynthTreeUI extends BasicTreeUI
paintingEnumerator
=
treeState
.
getVisiblePathsFrom
(
initialPath
);
paintingEnumerator
=
treeState
.
getVisiblePathsFrom
(
initialPath
);
while
(!
done
&&
paintingEnumerator
.
hasMoreElements
())
{
while
(!
done
&&
paintingEnumerator
.
hasMoreElements
())
{
path
=
(
TreePath
)
paintingEnumerator
.
nextElement
();
path
=
(
TreePath
)
paintingEnumerator
.
nextElement
();
if
(
path
!=
null
)
{
bounds
=
getPathBounds
(
tree
,
path
);
if
((
path
!=
null
)
&&
(
bounds
!=
null
))
{
isLeaf
=
treeModel
.
isLeaf
(
path
.
getLastPathComponent
());
isLeaf
=
treeModel
.
isLeaf
(
path
.
getLastPathComponent
());
if
(
isLeaf
)
{
if
(
isLeaf
)
{
isExpanded
=
hasBeenExpanded
=
false
;
isExpanded
=
hasBeenExpanded
=
false
;
...
@@ -392,7 +393,6 @@ public class SynthTreeUI extends BasicTreeUI
...
@@ -392,7 +393,6 @@ public class SynthTreeUI extends BasicTreeUI
isExpanded
=
treeState
.
getExpandedState
(
path
);
isExpanded
=
treeState
.
getExpandedState
(
path
);
hasBeenExpanded
=
tree
.
hasBeenExpanded
(
path
);
hasBeenExpanded
=
tree
.
hasBeenExpanded
(
path
);
}
}
bounds
=
getPathBounds
(
tree
,
path
);
// See if the vertical line to the parent has been drawn.
// See if the vertical line to the parent has been drawn.
parentPath
=
path
.
getParentPath
();
parentPath
=
path
.
getParentPath
();
if
(
parentPath
!=
null
)
{
if
(
parentPath
!=
null
)
{
...
...
test/javax/swing/plaf/synth/Test8015926.java
0 → 100644
浏览文件 @
884e1998
/*
* Copyright (c) 2013, 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 8015926
* @summary Tests that there are no NPE during painting
* @author Sergey Malenkov
*/
import
javax.swing.JFrame
;
import
javax.swing.JTree
;
import
javax.swing.SwingUtilities
;
import
javax.swing.UIManager
;
import
javax.swing.event.TreeModelEvent
;
import
javax.swing.event.TreeModelListener
;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
javax.swing.tree.DefaultTreeModel
;
import
static
javax
.
swing
.
WindowConstants
.
DISPOSE_ON_CLOSE
;
public
class
Test8015926
implements
TreeModelListener
,
Runnable
,
Thread
.
UncaughtExceptionHandler
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
UIManager
.
setLookAndFeel
(
"javax.swing.plaf.nimbus.NimbusLookAndFeel"
);
SwingUtilities
.
invokeAndWait
(
new
Test8015926
());
Thread
.
sleep
(
1000L
);
}
private
JTree
tree
;
@Override
public
void
treeStructureChanged
(
TreeModelEvent
event
)
{
}
@Override
public
void
treeNodesRemoved
(
TreeModelEvent
event
)
{
}
@Override
public
void
treeNodesInserted
(
TreeModelEvent
event
)
{
this
.
tree
.
expandPath
(
event
.
getTreePath
());
}
@Override
public
void
treeNodesChanged
(
TreeModelEvent
event
)
{
}
@Override
public
void
run
()
{
Thread
.
currentThread
().
setUncaughtExceptionHandler
(
this
);
DefaultMutableTreeNode
root
=
new
DefaultMutableTreeNode
();
DefaultMutableTreeNode
child
=
new
DefaultMutableTreeNode
(
"Child"
);
DefaultTreeModel
model
=
new
DefaultTreeModel
(
root
);
this
.
tree
=
new
JTree
();
this
.
tree
.
setModel
(
model
);
JFrame
frame
=
new
JFrame
(
getClass
().
getSimpleName
());
frame
.
add
(
this
.
tree
);
model
.
addTreeModelListener
(
this
);
// frame is not visible yet
model
.
insertNodeInto
(
child
,
root
,
root
.
getChildCount
());
model
.
removeNodeFromParent
(
child
);
frame
.
setSize
(
640
,
480
);
frame
.
setLocationRelativeTo
(
null
);
frame
.
setDefaultCloseOperation
(
DISPOSE_ON_CLOSE
);
frame
.
setVisible
(
true
);
}
@Override
public
void
uncaughtException
(
Thread
thread
,
Throwable
exception
)
{
exception
.
printStackTrace
();
System
.
exit
(
1
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录