Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5796390f
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看板
提交
5796390f
编写于
11月 29, 2010
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6981576: TitledBorder.getBorder() returns null in java build 1.7.0-ea-b107
Reviewed-by: alexp
上级
618a28ae
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
154 addition
and
45 deletion
+154
-45
src/share/classes/javax/swing/border/TitledBorder.java
src/share/classes/javax/swing/border/TitledBorder.java
+63
-45
test/javax/swing/border/Test6981576.java
test/javax/swing/border/Test6981576.java
+91
-0
未找到文件。
src/share/classes/javax/swing/border/TitledBorder.java
浏览文件 @
5796390f
...
...
@@ -165,11 +165,11 @@ public class TitledBorder extends AbstractBorder
* @param titlePosition the position for the title
*/
public
TitledBorder
(
Border
border
,
String
title
,
int
titleJustification
,
int
titlePosition
)
{
String
title
,
int
titleJustification
,
int
titlePosition
)
{
this
(
border
,
title
,
titleJustification
,
titlePosition
,
null
,
null
);
titlePosition
,
null
,
null
);
}
/**
...
...
@@ -183,12 +183,12 @@ public class TitledBorder extends AbstractBorder
* @param titleFont the font for rendering the title
*/
public
TitledBorder
(
Border
border
,
String
title
,
int
titleJustification
,
int
titlePosition
,
Font
titleFont
)
{
String
title
,
int
titleJustification
,
int
titlePosition
,
Font
titleFont
)
{
this
(
border
,
title
,
titleJustification
,
titlePosition
,
titleFont
,
null
);
titlePosition
,
titleFont
,
null
);
}
/**
...
...
@@ -205,11 +205,11 @@ public class TitledBorder extends AbstractBorder
*/
@ConstructorProperties
({
"border"
,
"title"
,
"titleJustification"
,
"titlePosition"
,
"titleFont"
,
"titleColor"
})
public
TitledBorder
(
Border
border
,
String
title
,
int
titleJustification
,
int
titlePosition
,
Font
titleFont
,
Color
titleColor
)
{
String
title
,
int
titleJustification
,
int
titlePosition
,
Font
titleFont
,
Color
titleColor
)
{
this
.
title
=
title
;
this
.
border
=
border
;
this
.
titleFont
=
titleFont
;
...
...
@@ -234,7 +234,7 @@ public class TitledBorder extends AbstractBorder
* @param height the height of the painted border
*/
public
void
paintBorder
(
Component
c
,
Graphics
g
,
int
x
,
int
y
,
int
width
,
int
height
)
{
Border
border
=
getBorder
UI
();
Border
border
=
getBorder
();
String
title
=
getTitle
();
if
((
title
!=
null
)
&&
!
title
.
isEmpty
())
{
int
edge
=
(
border
instanceof
TitledBorder
)
?
0
:
EDGE_SPACING
;
...
...
@@ -347,7 +347,7 @@ public class TitledBorder extends AbstractBorder
* @param insets the object to be reinitialized
*/
public
Insets
getBorderInsets
(
Component
c
,
Insets
insets
)
{
Border
border
=
getBorder
UI
();
Border
border
=
getBorder
();
if
(
border
==
null
)
{
insets
.
set
(
0
,
0
,
0
,
0
);
}
...
...
@@ -402,22 +402,34 @@ public class TitledBorder extends AbstractBorder
/**
* Returns whether or not the border is opaque.
*/
public
boolean
isBorderOpaque
()
{
return
false
;
}
public
boolean
isBorderOpaque
()
{
return
false
;
}
/**
* Returns the title of the titled border.
*
* @return the title of the titled border
*/
public
String
getTitle
()
{
return
title
;
}
public
String
getTitle
()
{
return
title
;
}
/**
* Returns the border of the titled border.
*
* @return the border of the titled border
*/
public
Border
getBorder
()
{
return
border
;
return
border
!=
null
?
border
:
UIManager
.
getBorder
(
"TitledBorder.border"
);
}
/**
* Returns the title-position of the titled border.
*
* @return the title-position of the titled border
*/
public
int
getTitlePosition
()
{
return
titlePosition
;
...
...
@@ -425,20 +437,28 @@ public class TitledBorder extends AbstractBorder
/**
* Returns the title-justification of the titled border.
*
* @return the title-justification of the titled border
*/
public
int
getTitleJustification
()
{
return
titleJustification
;
}
public
int
getTitleJustification
()
{
return
titleJustification
;
}
/**
* Returns the title-font of the titled border.
*
* @return the title-font of the titled border
*/
public
Font
getTitleFont
()
{
public
Font
getTitleFont
()
{
return
titleFont
;
}
/**
* Returns the title-color of the titled border.
*
* @return the title-color of the titled border
*/
public
Color
getTitleColor
()
{
public
Color
getTitleColor
()
{
return
titleColor
;
}
...
...
@@ -447,15 +467,19 @@ public class TitledBorder extends AbstractBorder
/**
* Sets the title of the titled border.
*
param title
the title for the border
*
@param title
the title for the border
*/
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
/**
* Sets the border of the titled border.
* @param border the border
*/
public
void
setBorder
(
Border
border
)
{
this
.
border
=
border
;
}
public
void
setBorder
(
Border
border
)
{
this
.
border
=
border
;
}
/**
* Sets the title-position of the titled border.
...
...
@@ -482,19 +506,19 @@ public class TitledBorder extends AbstractBorder
* Sets the title-justification of the titled border.
* @param titleJustification the justification for the border
*/
public
void
setTitleJustification
(
int
titleJustification
)
{
public
void
setTitleJustification
(
int
titleJustification
)
{
switch
(
titleJustification
)
{
case
DEFAULT_JUSTIFICATION:
case
LEFT:
case
CENTER:
case
RIGHT:
case
LEADING:
case
TRAILING:
this
.
titleJustification
=
titleJustification
;
break
;
default
:
throw
new
IllegalArgumentException
(
titleJustification
+
" is not a valid title justification."
);
case
DEFAULT_JUSTIFICATION:
case
LEFT:
case
CENTER:
case
RIGHT:
case
LEADING:
case
TRAILING:
this
.
titleJustification
=
titleJustification
;
break
;
default
:
throw
new
IllegalArgumentException
(
titleJustification
+
" is not a valid title justification."
);
}
}
...
...
@@ -518,6 +542,7 @@ public class TitledBorder extends AbstractBorder
* Returns the minimum dimensions this border requires
* in order to fully display the border and title.
* @param c the component where this border will be drawn
* @return the {@code Dimension} object
*/
public
Dimension
getMinimumSize
(
Component
c
)
{
Insets
insets
=
getBorderInsets
(
c
);
...
...
@@ -557,7 +582,7 @@ public class TitledBorder extends AbstractBorder
if
(
height
<
0
)
{
throw
new
IllegalArgumentException
(
"Height must be >= 0"
);
}
Border
border
=
getBorder
UI
();
Border
border
=
getBorder
();
String
title
=
getTitle
();
if
((
title
!=
null
)
&&
!
title
.
isEmpty
())
{
int
edge
=
(
border
instanceof
TitledBorder
)
?
0
:
EDGE_SPACING
;
...
...
@@ -616,13 +641,6 @@ public class TitledBorder extends AbstractBorder
return
Component
.
BaselineResizeBehavior
.
OTHER
;
}
private
Border
getBorderUI
()
{
Border
border
=
getBorder
();
return
border
!=
null
?
border
:
UIManager
.
getBorder
(
"TitledBorder.border"
);
}
private
int
getPosition
()
{
int
position
=
getTitlePosition
();
if
(
position
!=
DEFAULT_POSITION
)
{
...
...
test/javax/swing/border/Test6981576.java
0 → 100644
浏览文件 @
5796390f
/*
* Copyright (c) 2010, 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 6981576
* @summary Tests that default border for the titled border is not null
* @author Sergey Malenkov
*/
import
java.awt.Component
;
import
java.awt.Graphics
;
import
javax.swing.JFrame
;
import
javax.swing.JPanel
;
import
javax.swing.SwingUtilities
;
import
javax.swing.UIManager
;
import
javax.swing.UIManager.LookAndFeelInfo
;
import
javax.swing.border.TitledBorder
;
public
class
Test6981576
extends
TitledBorder
implements
Runnable
,
Thread
.
UncaughtExceptionHandler
{
public
static
void
main
(
String
[]
args
)
{
SwingUtilities
.
invokeLater
(
new
Test6981576
());
}
private
int
index
;
private
LookAndFeelInfo
[]
infos
;
private
JFrame
frame
;
private
Test6981576
()
{
super
(
""
);
}
@Override
public
void
paintBorder
(
Component
c
,
Graphics
g
,
int
x
,
int
y
,
int
width
,
int
height
)
{
getBorder
().
paintBorder
(
c
,
g
,
x
,
y
,
width
,
height
);
}
public
void
run
()
{
if
(
this
.
infos
==
null
)
{
this
.
infos
=
UIManager
.
getInstalledLookAndFeels
();
Thread
.
currentThread
().
setUncaughtExceptionHandler
(
this
);
JPanel
panel
=
new
JPanel
();
panel
.
setBorder
(
this
);
this
.
frame
=
new
JFrame
(
getClass
().
getSimpleName
());
this
.
frame
.
add
(
panel
);
this
.
frame
.
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
this
.
frame
.
setVisible
(
true
);
}
if
(
this
.
index
==
this
.
infos
.
length
)
{
this
.
frame
.
dispose
();
}
else
{
LookAndFeelInfo
info
=
this
.
infos
[
this
.
index
%
this
.
infos
.
length
];
try
{
UIManager
.
setLookAndFeel
(
info
.
getClassName
());
}
catch
(
Exception
exception
)
{
System
.
err
.
println
(
"could not change look and feel"
);
}
SwingUtilities
.
updateComponentTreeUI
(
this
.
frame
);
this
.
frame
.
pack
();
this
.
frame
.
setLocationRelativeTo
(
null
);
this
.
index
++;
SwingUtilities
.
invokeLater
(
this
);
}
}
public
void
uncaughtException
(
Thread
thread
,
Throwable
throwable
)
{
System
.
exit
(
1
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录