Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b40b52ba
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看板
提交
b40b52ba
编写于
5月 26, 2010
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6925473: REGRESSION: JOptionPane in dialog is full-screen height
Reviewed-by: peterz
上级
c1fe285e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
186 addition
and
101 deletion
+186
-101
src/share/classes/javax/swing/text/WrappedPlainView.java
src/share/classes/javax/swing/text/WrappedPlainView.java
+4
-60
test/javax/swing/JTextArea/6925473/bug6925473.java
test/javax/swing/JTextArea/6925473/bug6925473.java
+64
-0
test/javax/swing/JTextArea/6940863/bug6940863.java
test/javax/swing/JTextArea/6940863/bug6940863.java
+87
-0
test/javax/swing/JTextArea/Test6593649.java
test/javax/swing/JTextArea/Test6593649.java
+31
-41
未找到文件。
src/share/classes/javax/swing/text/WrappedPlainView.java
浏览文件 @
b40b52ba
...
@@ -24,8 +24,6 @@
...
@@ -24,8 +24,6 @@
*/
*/
package
javax.swing.text
;
package
javax.swing.text
;
import
java.util.Vector
;
import
java.util.Properties
;
import
java.awt.*
;
import
java.awt.*
;
import
java.lang.ref.SoftReference
;
import
java.lang.ref.SoftReference
;
import
javax.swing.event.*
;
import
javax.swing.event.*
;
...
@@ -236,9 +234,6 @@ public class WrappedPlainView extends BoxView implements TabExpander {
...
@@ -236,9 +234,6 @@ public class WrappedPlainView extends BoxView implements TabExpander {
Segment
segment
=
SegmentCache
.
getSharedSegment
();
Segment
segment
=
SegmentCache
.
getSharedSegment
();
loadText
(
segment
,
p0
,
p1
);
loadText
(
segment
,
p0
,
p1
);
int
currentWidth
=
getWidth
();
int
currentWidth
=
getWidth
();
if
(
currentWidth
==
Integer
.
MAX_VALUE
)
{
currentWidth
=
(
int
)
getDefaultSpan
(
View
.
X_AXIS
);
}
if
(
wordWrap
)
{
if
(
wordWrap
)
{
p
=
p0
+
Utilities
.
getBreakLocation
(
segment
,
metrics
,
p
=
p0
+
Utilities
.
getBreakLocation
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
tabBase
,
tabBase
+
currentWidth
,
...
@@ -324,53 +319,6 @@ public class WrappedPlainView extends BoxView implements TabExpander {
...
@@ -324,53 +319,6 @@ public class WrappedPlainView extends BoxView implements TabExpander {
tabSize
=
getTabSize
()
*
metrics
.
charWidth
(
'm'
);
tabSize
=
getTabSize
()
*
metrics
.
charWidth
(
'm'
);
}
}
/**
* Return reasonable default values for the view dimensions. The standard
* text terminal size 80x24 is pretty suitable for the wrapped plain view.
*
* The size should not be larger than the component housing the view's
* container.
*/
private
float
getDefaultSpan
(
int
axis
)
{
Container
host
=
getContainer
();
Component
parent
=
null
;
if
(
host
!=
null
)
{
parent
=
host
.
getParent
();
}
switch
(
axis
)
{
case
View
.
X_AXIS
:
int
defaultWidth
=
80
*
metrics
.
getWidths
()[
'M'
];
int
parentWidth
=
0
;
if
(
parent
!=
null
)
{
parentWidth
=
parent
.
getWidth
();
}
if
(
defaultWidth
>
parentWidth
)
{
return
parentWidth
;
}
return
defaultWidth
;
case
View
.
Y_AXIS
:
int
defaultHeight
=
24
*
metrics
.
getHeight
();
int
parentHeight
=
0
;
if
(
parent
!=
null
)
{
parentHeight
=
parent
.
getHeight
();
}
if
(
defaultHeight
>
parentHeight
)
{
return
parentHeight
;
}
return
defaultHeight
;
default
:
throw
new
IllegalArgumentException
(
"Invalid axis: "
+
axis
);
}
}
// --- TabExpander methods ------------------------------------------
// --- TabExpander methods ------------------------------------------
/**
/**
...
@@ -605,18 +553,14 @@ public class WrappedPlainView extends BoxView implements TabExpander {
...
@@ -605,18 +553,14 @@ public class WrappedPlainView extends BoxView implements TabExpander {
if
(
width
==
Integer
.
MAX_VALUE
)
{
if
(
width
==
Integer
.
MAX_VALUE
)
{
// We have been initially set to MAX_VALUE, but we don't
// We have been initially set to MAX_VALUE, but we don't
// want this as our preferred.
// want this as our preferred.
width
=
getDefaultSpan
(
axis
)
;
return
100
f
;
}
}
return
width
;
return
width
;
case
View
.
Y_AXIS
:
case
View
.
Y_AXIS
:
if
(
getDocument
().
getLength
()
>
0
)
{
if
(
lineCount
<
0
||
widthChanging
)
{
if
((
lineCount
<
0
)
||
widthChanging
)
{
breakLines
(
getStartOffset
());
breakLines
(
getStartOffset
());
}
return
lineCount
*
metrics
.
getHeight
();
}
else
{
return
getDefaultSpan
(
axis
);
}
}
return
lineCount
*
metrics
.
getHeight
();
default
:
default
:
throw
new
IllegalArgumentException
(
"Invalid axis: "
+
axis
);
throw
new
IllegalArgumentException
(
"Invalid axis: "
+
axis
);
}
}
...
...
test/javax/swing/JTextArea/6925473/bug6925473.java
0 → 100644
浏览文件 @
b40b52ba
/*
* Copyright 2010 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
* @bug 6925473
* @summary REGRESSION: JOptionPane in dialog is full-screen height
* @author Pavel Porvatov
* @run main bug6925473
*/
import
javax.swing.*
;
import
java.awt.*
;
public
class
bug6925473
{
private
static
final
String
LONG_TEXT
=
"Copyright 2010 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. "
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
JTextArea
textArea
=
new
JTextArea
(
LONG_TEXT
);
Dimension
preferredSize
=
textArea
.
getPreferredSize
();
if
(
preferredSize
.
width
<=
0
||
preferredSize
.
height
<=
0
)
{
throw
new
RuntimeException
(
"Invalid preferred size "
+
preferredSize
);
}
JTextArea
textAreaLW
=
new
JTextArea
(
LONG_TEXT
);
textAreaLW
.
setLineWrap
(
true
);
Dimension
preferredSizeLW
=
textAreaLW
.
getPreferredSize
();
if
(
preferredSizeLW
.
width
<=
0
||
preferredSizeLW
.
height
<=
0
)
{
throw
new
RuntimeException
(
"Invalid preferred size "
+
preferredSizeLW
);
}
}
});
}
}
test/javax/swing/JTextArea/6940863/bug6940863.java
0 → 100644
浏览文件 @
b40b52ba
/*
* Copyright 2010 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
* @bug 6940863
* @summary Textarea within scrollpane shows vertical scrollbar
* @author Pavel Porvatov
* @run main bug6940863
*/
import
sun.awt.OSInfo
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
public
class
bug6940863
{
private
static
JFrame
frame
;
private
static
JScrollPane
scrollPane
;
private
static
final
Timer
timer
=
new
Timer
(
1000
,
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
boolean
failed
=
scrollPane
.
getVerticalScrollBar
().
isShowing
()
||
scrollPane
.
getHorizontalScrollBar
().
isShowing
();
frame
.
dispose
();
if
(
failed
)
{
throw
new
RuntimeException
(
"The test failed"
);
}
}
});
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
OSInfo
.
getOSType
()
!=
OSInfo
.
OSType
.
WINDOWS
)
{
System
.
out
.
println
(
"The test is suitable only for Windows OS. Skipped"
);
}
UIManager
.
setLookAndFeel
(
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
);
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
JTextArea
textArea
=
new
JTextArea
();
textArea
.
setLineWrap
(
true
);
textArea
.
setWrapStyleWord
(
true
);
scrollPane
=
new
JScrollPane
(
textArea
);
scrollPane
.
setMinimumSize
(
new
Dimension
(
200
,
100
));
scrollPane
.
setPreferredSize
(
new
Dimension
(
300
,
150
));
frame
=
new
JFrame
(
"Vertical scrollbar shown without text"
);
frame
.
setContentPane
(
scrollPane
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
pack
();
frame
.
setVisible
(
true
);
timer
.
setRepeats
(
false
);
timer
.
start
();
}
});
}
}
test/javax/swing/JTextArea/Test6593649.java
浏览文件 @
b40b52ba
...
@@ -30,60 +30,50 @@
...
@@ -30,60 +30,50 @@
import
javax.swing.*
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
public
class
Test6593649
extends
JFrame
{
public
class
Test6593649
{
static
JTextArea
txt
;
private
static
JFrame
frame
;
static
JPanel
innerPanel
;
public
Test6593649
(
Dimension
d
)
private
static
JTextArea
textArea
;
{
super
(
"Word Wrap Testcase"
);
setSize
(
d
);
private
static
final
Timer
timer
=
new
Timer
(
1000
,
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
boolean
failed
=
!
textArea
.
getParent
().
getSize
().
equals
(
textArea
.
getSize
());
final
Container
contentPane
=
getContentPan
e
();
frame
.
dispos
e
();
innerPanel
=
new
JPanel
();
if
(
failed
)
{
innerPanel
.
setLayout
(
new
BoxLayout
(
innerPanel
,
BoxLayout
.
LINE_AXIS
));
throw
new
RuntimeException
(
"The test failed"
);
}
}
});
txt
=
new
JTextArea
(
"This is a long line that should wrap, but doesn't..."
);
public
static
void
main
(
String
[]
args
)
throws
Exception
{
txt
.
setLineWrap
(
true
);
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
txt
.
setWrapStyleWord
(
true
);
public
void
run
()
{
frame
=
new
JFrame
();
innerPanel
.
add
(
txt
);
frame
.
setSize
(
200
,
100
);
contentPane
.
add
(
innerPanel
,
BorderLayout
.
SOUTH
);
textArea
=
new
JTextArea
(
"This is a long line that should wrap, but doesn't..."
);
}
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
textArea
.
setLineWrap
(
true
);
{
textArea
.
setWrapStyleWord
(
true
);
int
size
=
100
;
Dimension
d
;
Test6593649
cp
;
Dimension
txtSize
;
Dimension
innerSize
;
Dimension
cpSize
;
while
(
size
<=
600
)
JPanel
innerPanel
=
new
JPanel
();
{
d
=
new
Dimension
(
size
,
size
);
cp
=
new
Test6593649
(
d
);
cp
.
setVisible
(
true
);
txtSize
=
txt
.
getPreferredSize
();
innerPanel
.
setLayout
(
new
BoxLayout
(
innerPanel
,
BoxLayout
.
LINE_AXIS
));
innerSize
=
innerPanel
.
getPreferredSize
();
innerPanel
.
add
(
textArea
);
cpSize
=
cp
.
getSize
();
if
(!(
txtSize
.
getWidth
()
==
innerPanel
.
getWidth
()
&&
txtSize
.
getHeight
()
==
innerPanel
.
getHeight
()
&&
frame
.
getContentPane
().
add
(
innerPanel
,
BorderLayout
.
SOUTH
);
txtSize
.
getWidth
()
<=
cpSize
.
getWidth
()
&&
txtSize
.
getHeight
()
<=
cpSize
.
getHeight
()))
{
throw
new
RuntimeException
(
"Test failed: Text area size does not properly match panel and frame sizes"
);
}
Thread
.
sleep
(
2000
);
frame
.
setVisible
(
true
);
cp
.
hide
();
timer
.
setRepeats
(
false
);
size
+=
50
;
timer
.
start
();
}
});
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录