Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
8f2e3430
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看板
提交
8f2e3430
编写于
6月 21, 2010
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
cef049d8
48626e23
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
768 addition
and
72 deletion
+768
-72
src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
...es/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
+1
-1
src/share/classes/javax/swing/BorderFactory.java
src/share/classes/javax/swing/BorderFactory.java
+123
-6
src/share/classes/javax/swing/plaf/synth/SynthParser.java
src/share/classes/javax/swing/plaf/synth/SynthParser.java
+1
-2
src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
+59
-43
src/share/classes/javax/swing/text/DefaultStyledDocument.java
...share/classes/javax/swing/text/DefaultStyledDocument.java
+13
-8
src/share/classes/javax/swing/text/GlyphView.java
src/share/classes/javax/swing/text/GlyphView.java
+1
-1
src/share/classes/javax/swing/text/Utilities.java
src/share/classes/javax/swing/text/Utilities.java
+19
-1
src/share/classes/javax/swing/text/WrappedPlainView.java
src/share/classes/javax/swing/text/WrappedPlainView.java
+6
-4
src/share/classes/javax/swing/text/html/HTMLDocument.java
src/share/classes/javax/swing/text/html/HTMLDocument.java
+1
-5
src/share/classes/sun/swing/SwingUtilities2.java
src/share/classes/sun/swing/SwingUtilities2.java
+6
-0
src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java
...asses/sun/swing/table/DefaultTableCellHeaderRenderer.java
+1
-1
test/javax/swing/JTable/6788484/bug6788484.java
test/javax/swing/JTable/6788484/bug6788484.java
+39
-0
test/javax/swing/plaf/synth/6771547/SynthTest.java
test/javax/swing/plaf/synth/6771547/SynthTest.java
+50
-0
test/javax/swing/plaf/synth/6771547/synthconfig.xml
test/javax/swing/plaf/synth/6771547/synthconfig.xml
+10
-0
test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java
...x/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java
+59
-0
test/javax/swing/text/DefaultStyledDocument/6636983/bug6636983.java
.../swing/text/DefaultStyledDocument/6636983/bug6636983.java
+152
-0
test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java
...wing/text/WrappedPlainView/6857057/StubBranchElement.java
+87
-0
test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java
.../swing/text/WrappedPlainView/6857057/StubLeafElement.java
+81
-0
test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java
...javax/swing/text/WrappedPlainView/6857057/bug6857057.java
+59
-0
未找到文件。
src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
浏览文件 @
8f2e3430
...
...
@@ -424,7 +424,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
State
rv
;
rv
=
super
.
getState
();
if
(
rv
!=
State
.
DISABLED
&&
!
comboBox
.
isEditable
()
&&
comboBox
!=
null
&&
!
comboBox
.
isEditable
()
&&
XPStyle
.
getXP
().
isSkinDefined
(
comboBox
,
Part
.
CP_DROPDOWNBUTTONRIGHT
))
{
/*
...
...
src/share/classes/javax/swing/BorderFactory.java
浏览文件 @
8f2e3430
/*
* Copyright (c) 1997, 20
05
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 20
10
, 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
...
...
@@ -26,7 +26,6 @@ package javax.swing;
import
java.awt.Color
;
import
java.awt.Font
;
import
javax.swing.JComponent
;
import
javax.swing.border.*
;
/**
...
...
@@ -74,10 +73,20 @@ public class BorderFactory
return
new
LineBorder
(
color
,
thickness
);
}
// public static Border createLineBorder(Color color, int thickness,
// boolean drawRounded) {
// return new JLineBorder(color, thickness, drawRounded);
// }
/**
* Creates a line border with the specified color, thickness, and corner shape.
*
* @param color the color of the border
* @param thickness the thickness of the border
* @param rounded whether or not border corners should be round
* @return the {@code Border} object
*
* @see LineBorder#LineBorder(Color, int, boolean)
* @since 1.7
*/
public
static
Border
createLineBorder
(
Color
color
,
int
thickness
,
boolean
rounded
)
{
return
new
LineBorder
(
color
,
thickness
,
rounded
);
}
//// BevelBorder /////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -180,7 +189,115 @@ public class BorderFactory
}
return
null
;
}
//// SoftBevelBorder ///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
private
static
Border
sharedSoftRaisedBevel
;
private
static
Border
sharedSoftLoweredBevel
;
/**
* Creates a beveled border with a raised edge and softened corners,
* using brighter shades of the component's current background color
* for highlighting, and darker shading for shadows.
* In a raised border, highlights are on top and shadows are underneath.
*
* @return the {@code Border} object
*
* @since 1.7
*/
public
static
Border
createRaisedSoftBevelBorder
()
{
if
(
sharedSoftRaisedBevel
==
null
)
{
sharedSoftRaisedBevel
=
new
SoftBevelBorder
(
BevelBorder
.
RAISED
);
}
return
sharedSoftRaisedBevel
;
}
/**
* Creates a beveled border with a lowered edge and softened corners,
* using brighter shades of the component's current background color
* for highlighting, and darker shading for shadows.
* In a lowered border, shadows are on top and highlights are underneath.
*
* @return the {@code Border} object
*
* @since 1.7
*/
public
static
Border
createLoweredSoftBevelBorder
()
{
if
(
sharedSoftLoweredBevel
==
null
)
{
sharedSoftLoweredBevel
=
new
SoftBevelBorder
(
BevelBorder
.
LOWERED
);
}
return
sharedSoftLoweredBevel
;
}
/**
* Creates a beveled border of the specified type with softened corners,
* using brighter shades of the component's current background color
* for highlighting, and darker shading for shadows.
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.
*
* @param type a type of a bevel
* @return the {@code Border} object or {@code null}
* if the specified type is not valid
*
* @see BevelBorder#BevelBorder(int)
* @since 1.7
*/
public
static
Border
createSoftBevelBorder
(
int
type
)
{
if
(
type
==
BevelBorder
.
RAISED
)
{
return
createRaisedSoftBevelBorder
();
}
if
(
type
==
BevelBorder
.
LOWERED
)
{
return
createLoweredSoftBevelBorder
();
}
return
null
;
}
/**
* Creates a beveled border of the specified type with softened corners,
* using the specified highlighting and shadowing.
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.
* The outer edge of the highlight area uses
* a brighter shade of the {@code highlight} color.
* The inner edge of the shadow area uses
* a brighter shade of the {@code shadow} color.
*
* @param type a type of a bevel
* @param highlight a basic color of the highlight area
* @param shadow a basic color of the shadow area
* @return the {@code Border} object
*
* @see BevelBorder#BevelBorder(int, Color, Color)
* @since 1.7
*/
public
static
Border
createSoftBevelBorder
(
int
type
,
Color
highlight
,
Color
shadow
)
{
return
new
BevelBorder
(
type
,
highlight
,
shadow
);
}
/**
* Creates a beveled border of the specified type with softened corners,
* using the specified colors for the inner and outer edges
* of the highlight and the shadow areas.
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.
* Note: The shadow inner and outer colors are switched
* for a lowered bevel border.
*
* @param type a type of a bevel
* @param highlightOuter a color of the outer edge of the highlight area
* @param highlightInner a color of the inner edge of the highlight area
* @param shadowOuter a color of the outer edge of the shadow area
* @param shadowInner a color of the inner edge of the shadow area
* @return the {@code Border} object
*
* @see BevelBorder#BevelBorder(int, Color, Color, Color, Color)
* @since 1.7
*/
public
static
Border
createSoftBevelBorder
(
int
type
,
Color
highlightOuter
,
Color
highlightInner
,
Color
shadowOuter
,
Color
shadowInner
)
{
return
new
BevelBorder
(
type
,
highlightOuter
,
highlightInner
,
shadowOuter
,
shadowInner
);
}
//// EtchedBorder ///////////////////////////////////////////////////////////
static
final
Border
sharedEtchedBorder
=
new
EtchedBorder
();
private
static
Border
sharedRaisedEtchedBorder
;
...
...
src/share/classes/javax/swing/plaf/synth/SynthParser.java
浏览文件 @
8f2e3430
...
...
@@ -658,8 +658,7 @@ class SynthParser extends DefaultHandler {
}
try
{
_colorTypes
.
add
((
ColorType
)
checkCast
(
typeClass
.
getField
(
typeName
.
substring
(
classIndex
,
typeName
.
length
()
-
classIndex
)).
getField
(
typeName
.
substring
(
classIndex
)).
get
(
typeClass
),
ColorType
.
class
));
}
catch
(
NoSuchFieldException
nsfe
)
{
throw
new
SAXException
(
"Unable to find color type: "
+
...
...
src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
浏览文件 @
8f2e3430
...
...
@@ -363,18 +363,24 @@ public class SynthToolBarUI extends BasicToolBarUI
SynthIcon
.
getIconWidth
(
handleIcon
,
context
)
:
0
;
Dimension
compDim
;
for
(
int
i
=
0
;
i
<
tb
.
getComponentCount
();
i
++)
{
compDim
=
tb
.
getComponent
(
i
).
getMinimumSize
();
dim
.
width
+=
compDim
.
width
;
dim
.
height
=
Math
.
max
(
dim
.
height
,
compDim
.
height
);
Component
component
=
tb
.
getComponent
(
i
);
if
(
component
.
isVisible
())
{
compDim
=
component
.
getMinimumSize
();
dim
.
width
+=
compDim
.
width
;
dim
.
height
=
Math
.
max
(
dim
.
height
,
compDim
.
height
);
}
}
}
else
{
dim
.
height
=
tb
.
isFloatable
()
?
SynthIcon
.
getIconHeight
(
handleIcon
,
context
)
:
0
;
Dimension
compDim
;
for
(
int
i
=
0
;
i
<
tb
.
getComponentCount
();
i
++)
{
compDim
=
tb
.
getComponent
(
i
).
getMinimumSize
();
dim
.
width
=
Math
.
max
(
dim
.
width
,
compDim
.
width
);
dim
.
height
+=
compDim
.
height
;
Component
component
=
tb
.
getComponent
(
i
);
if
(
component
.
isVisible
())
{
compDim
=
component
.
getMinimumSize
();
dim
.
width
=
Math
.
max
(
dim
.
width
,
compDim
.
width
);
dim
.
height
+=
compDim
.
height
;
}
}
}
dim
.
width
+=
insets
.
left
+
insets
.
right
;
...
...
@@ -395,18 +401,24 @@ public class SynthToolBarUI extends BasicToolBarUI
SynthIcon
.
getIconWidth
(
handleIcon
,
context
)
:
0
;
Dimension
compDim
;
for
(
int
i
=
0
;
i
<
tb
.
getComponentCount
();
i
++)
{
compDim
=
tb
.
getComponent
(
i
).
getPreferredSize
();
dim
.
width
+=
compDim
.
width
;
dim
.
height
=
Math
.
max
(
dim
.
height
,
compDim
.
height
);
Component
component
=
tb
.
getComponent
(
i
);
if
(
component
.
isVisible
())
{
compDim
=
component
.
getPreferredSize
();
dim
.
width
+=
compDim
.
width
;
dim
.
height
=
Math
.
max
(
dim
.
height
,
compDim
.
height
);
}
}
}
else
{
dim
.
height
=
tb
.
isFloatable
()
?
SynthIcon
.
getIconHeight
(
handleIcon
,
context
)
:
0
;
Dimension
compDim
;
for
(
int
i
=
0
;
i
<
tb
.
getComponentCount
();
i
++)
{
compDim
=
tb
.
getComponent
(
i
).
getPreferredSize
();
dim
.
width
=
Math
.
max
(
dim
.
width
,
compDim
.
width
);
dim
.
height
+=
compDim
.
height
;
Component
component
=
tb
.
getComponent
(
i
);
if
(
component
.
isVisible
())
{
compDim
=
component
.
getPreferredSize
();
dim
.
width
=
Math
.
max
(
dim
.
width
,
compDim
.
width
);
dim
.
height
+=
compDim
.
height
;
}
}
}
dim
.
width
+=
insets
.
left
+
insets
.
right
;
...
...
@@ -469,22 +481,24 @@ public class SynthToolBarUI extends BasicToolBarUI
for
(
int
i
=
0
;
i
<
tb
.
getComponentCount
();
i
++)
{
c
=
tb
.
getComponent
(
i
);
d
=
c
.
getPreferredSize
();
int
y
,
h
;
if
(
d
.
height
>=
baseH
||
c
instanceof
JSeparator
)
{
// Fill available height
y
=
baseY
;
h
=
baseH
;
}
else
{
// Center component vertically in the available space
y
=
baseY
+
(
baseH
/
2
)
-
(
d
.
height
/
2
);
h
=
d
.
height
;
if
(
c
.
isVisible
())
{
d
=
c
.
getPreferredSize
();
int
y
,
h
;
if
(
d
.
height
>=
baseH
||
c
instanceof
JSeparator
)
{
// Fill available height
y
=
baseY
;
h
=
baseH
;
}
else
{
// Center component vertically in the available space
y
=
baseY
+
(
baseH
/
2
)
-
(
d
.
height
/
2
);
h
=
d
.
height
;
}
//if the component is a "glue" component then add to its
//width the extraSpacePerGlue it is due
if
(
isGlue
(
c
))
d
.
width
+=
extraSpacePerGlue
;
c
.
setBounds
(
ltr
?
x
:
x
-
d
.
width
,
y
,
d
.
width
,
h
);
x
=
ltr
?
x
+
d
.
width
:
x
-
d
.
width
;
}
//if the component is a "glue" component then add to its
//width the extraSpacePerGlue it is due
if
(
isGlue
(
c
))
d
.
width
+=
extraSpacePerGlue
;
c
.
setBounds
(
ltr
?
x
:
x
-
d
.
width
,
y
,
d
.
width
,
h
);
x
=
ltr
?
x
+
d
.
width
:
x
-
d
.
width
;
}
}
else
{
int
handleHeight
=
tb
.
isFloatable
()
?
...
...
@@ -512,29 +526,31 @@ public class SynthToolBarUI extends BasicToolBarUI
for
(
int
i
=
0
;
i
<
tb
.
getComponentCount
();
i
++)
{
c
=
tb
.
getComponent
(
i
);
d
=
c
.
getPreferredSize
();
int
x
,
w
;
if
(
d
.
width
>=
baseW
||
c
instanceof
JSeparator
)
{
// Fill available width
x
=
baseX
;
w
=
baseW
;
}
else
{
// Center component horizontally in the available space
x
=
baseX
+
(
baseW
/
2
)
-
(
d
.
width
/
2
);
w
=
d
.
width
;
if
(
c
.
isVisible
())
{
d
=
c
.
getPreferredSize
();
int
x
,
w
;
if
(
d
.
width
>=
baseW
||
c
instanceof
JSeparator
)
{
// Fill available width
x
=
baseX
;
w
=
baseW
;
}
else
{
// Center component horizontally in the available space
x
=
baseX
+
(
baseW
/
2
)
-
(
d
.
width
/
2
);
w
=
d
.
width
;
}
//if the component is a "glue" component then add to its
//height the extraSpacePerGlue it is due
if
(
isGlue
(
c
))
d
.
height
+=
extraSpacePerGlue
;
c
.
setBounds
(
x
,
y
,
w
,
d
.
height
);
y
+=
d
.
height
;
}
//if the component is a "glue" component then add to its
//height the extraSpacePerGlue it is due
if
(
isGlue
(
c
))
d
.
height
+=
extraSpacePerGlue
;
c
.
setBounds
(
x
,
y
,
w
,
d
.
height
);
y
+=
d
.
height
;
}
}
context
.
dispose
();
}
private
boolean
isGlue
(
Component
c
)
{
if
(
c
instanceof
Box
.
Filler
)
{
if
(
c
.
isVisible
()
&&
c
instanceof
Box
.
Filler
)
{
Box
.
Filler
f
=
(
Box
.
Filler
)
c
;
Dimension
min
=
f
.
getMinimumSize
();
Dimension
pref
=
f
.
getPreferredSize
();
...
...
src/share/classes/javax/swing/text/DefaultStyledDocument.java
浏览文件 @
8f2e3430
...
...
@@ -25,15 +25,12 @@
package
javax.swing.text
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.Font
;
import
java.awt.FontMetrics
;
import
java.awt.font.TextAttribute
;
import
java.lang.ref.ReferenceQueue
;
import
java.lang.ref.WeakReference
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Stack
;
...
...
@@ -41,15 +38,14 @@ import java.util.Vector;
import
java.util.ArrayList
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.io.Serializable
;
import
javax.swing.Icon
;
import
javax.swing.event.*
;
import
javax.swing.undo.AbstractUndoableEdit
;
import
javax.swing.undo.CannotRedoException
;
import
javax.swing.undo.CannotUndoException
;
import
javax.swing.undo.UndoableEdit
;
import
javax.swing.SwingUtilities
;
import
static
sun
.
swing
.
SwingUtilities2
.
IMPLIED_CR
;
/**
* A document that can be marked up with character and paragraph
...
...
@@ -782,9 +778,18 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
// Check for the composed text element. If it is, merge the character attributes
// into this element as well.
if
(
Utilities
.
isComposedTextAttributeDefined
(
attr
))
{
((
MutableAttributeSet
)
attr
).
addAttributes
(
cattr
);
((
MutableAttributeSet
)
attr
).
addAttribute
(
AbstractDocument
.
ElementNameAttribute
,
AbstractDocument
.
ContentElementName
);
MutableAttributeSet
mattr
=
(
MutableAttributeSet
)
attr
;
mattr
.
addAttributes
(
cattr
);
mattr
.
addAttribute
(
AbstractDocument
.
ElementNameAttribute
,
AbstractDocument
.
ContentElementName
);
// Assure that the composed text element is named properly
// and doesn't have the CR attribute defined.
mattr
.
addAttribute
(
StyleConstants
.
NameAttribute
,
AbstractDocument
.
ContentElementName
);
if
(
mattr
.
isDefined
(
IMPLIED_CR
))
{
mattr
.
removeAttribute
(
IMPLIED_CR
);
}
}
ElementSpec
[]
spec
=
new
ElementSpec
[
parseBuffer
.
size
()];
...
...
src/share/classes/javax/swing/text/GlyphView.java
浏览文件 @
8f2e3430
...
...
@@ -32,6 +32,7 @@ import java.util.Locale;
import
javax.swing.UIManager
;
import
sun.swing.SwingUtilities2
;
import
static
sun
.
swing
.
SwingUtilities2
.
IMPLIED_CR
;
/**
* A GlyphView is a styled chunk of text that represents a view
...
...
@@ -1061,7 +1062,6 @@ public class GlyphView extends View implements TabableView, Cloneable {
int
length
;
// if it is an implied newline character
boolean
impliedCR
;
private
static
final
String
IMPLIED_CR
=
"CR"
;
boolean
skipWidth
;
/**
...
...
src/share/classes/javax/swing/text/Utilities.java
浏览文件 @
8f2e3430
...
...
@@ -403,6 +403,24 @@ public class Utilities {
return
txtCount
;
}
/**
* Adjust text offset so that the length of a resulting string as a whole
* fits into the specified width.
*/
static
int
adjustOffsetForFractionalMetrics
(
Segment
s
,
FontMetrics
fm
,
int
offset
,
int
width
)
{
// Sometimes the offset returned by getTabbedTextOffset is beyond the
// available area, when fractional metrics are enabled. We should
// guard against this.
if
(
offset
<
s
.
count
)
{
while
(
offset
>
0
&&
fm
.
charsWidth
(
s
.
array
,
s
.
offset
,
offset
+
1
)
>
width
)
{
offset
--;
}
}
return
offset
;
}
/**
* Determine where to break the given text to fit
* within the given span. This tries to find a word boundary.
...
...
@@ -425,7 +443,7 @@ public class Utilities {
int
txtCount
=
s
.
count
;
int
index
=
Utilities
.
getTabbedTextOffset
(
s
,
metrics
,
x0
,
x
,
e
,
startOffset
,
false
);
index
=
adjustOffsetForFractionalMetrics
(
s
,
metrics
,
index
,
x
-
x0
);
if
(
index
>=
txtCount
-
1
)
{
return
txtCount
;
...
...
src/share/classes/javax/swing/text/WrappedPlainView.java
浏览文件 @
8f2e3430
...
...
@@ -108,7 +108,7 @@ public class WrappedPlainView extends BoxView implements TabExpander {
try
{
if
(
line
.
isLeaf
())
{
drawText
(
line
,
p0
,
p1
,
g
,
x
,
y
);
drawText
(
line
,
p0
,
p1
,
g
,
x
,
y
);
}
else
{
// this line contains the composed text.
int
idx
=
line
.
getElementIndex
(
p0
);
...
...
@@ -239,9 +239,11 @@ public class WrappedPlainView extends BoxView implements TabExpander {
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
);
}
else
{
p
=
p0
+
Utilities
.
getTabbedTextOffset
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
,
false
);
int
offset
=
Utilities
.
getTabbedTextOffset
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
,
false
);
offset
=
Utilities
.
adjustOffsetForFractionalMetrics
(
segment
,
metrics
,
offset
,
currentWidth
);
p
=
p0
+
offset
;
}
SegmentCache
.
releaseSharedSegment
(
segment
);
return
p
;
...
...
src/share/classes/javax/swing/text/html/HTMLDocument.java
浏览文件 @
8f2e3430
...
...
@@ -24,20 +24,17 @@
*/
package
javax.swing.text.html
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.font.TextAttribute
;
import
java.util.*
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.MalformedURLException
;
import
java.io.*
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
javax.swing.text.*
;
import
javax.swing.undo.*
;
import
java.text.Bidi
;
import
sun.swing.SwingUtilities2
;
import
static
sun
.
swing
.
SwingUtilities2
.
IMPLIED_CR
;
/**
* A document that models HTML. The purpose of this model is to
...
...
@@ -1819,7 +1816,6 @@ public class HTMLDocument extends DefaultStyledDocument {
static
String
MAP_PROPERTY
=
"__MAP__"
;
private
static
char
[]
NEWLINE
;
private
static
final
String
IMPLIED_CR
=
"CR"
;
/**
* I18N property key.
...
...
src/share/classes/sun/swing/SwingUtilities2.java
浏览文件 @
8f2e3430
...
...
@@ -108,6 +108,12 @@ public class SwingUtilities2 {
public
static
final
Object
AA_TEXT_PROPERTY_KEY
=
new
StringBuffer
(
"AATextInfoPropertyKey"
);
/**
* Attribute key for the content elements. If it is set on an element, the
* element is considered to be a line break.
*/
public
static
final
String
IMPLIED_CR
=
"CR"
;
/**
* Used to tell a text component, being used as an editor for table
* or tree, how many clicks it took to start editing.
...
...
src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java
浏览文件 @
8f2e3430
...
...
@@ -127,7 +127,7 @@ public class DefaultTableCellHeaderRenderer extends DefaultTableCellRenderer
public
static
SortOrder
getColumnSortOrder
(
JTable
table
,
int
column
)
{
SortOrder
rv
=
null
;
if
(
table
.
getRowSorter
()
==
null
)
{
if
(
table
==
null
||
table
.
getRowSorter
()
==
null
)
{
return
rv
;
}
java
.
util
.
List
<?
extends
RowSorter
.
SortKey
>
sortKeys
=
...
...
test/javax/swing/JTable/6788484/bug6788484.java
0 → 100644
浏览文件 @
8f2e3430
/*
* 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 6788484
@summary NPE in DefaultTableCellHeaderRenderer.getColumnSortOrder() with null table
@author Alexander Potochkin
@run main bug6788484
*/
import
sun.swing.table.DefaultTableCellHeaderRenderer
;
import
javax.swing.*
;
public
class
bug6788484
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
DefaultTableCellHeaderRenderer
.
getColumnSortOrder
(
null
,
0
);
}
}
test/javax/swing/plaf/synth/6771547/SynthTest.java
0 → 100644
浏览文件 @
8f2e3430
/*
* 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 6771547
* @author Alexander Potochkin
* @summary SynthParser throws StringIndexOutOfBoundsException parsing custom ColorTypes
*/
import
javax.swing.plaf.synth.SynthLookAndFeel
;
import
javax.swing.*
;
import
java.io.InputStream
;
import
java.awt.*
;
public
class
SynthTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SynthLookAndFeel
laf
=
new
SynthLookAndFeel
();
InputStream
in
=
SynthTest
.
class
.
getResourceAsStream
(
"synthconfig.xml"
);
laf
.
load
(
in
,
SynthTest
.
class
);
UIManager
.
setLookAndFeel
(
laf
);
if
(!
Color
.
RED
.
equals
(
new
JButton
().
getForeground
()))
{
throw
new
RuntimeException
(
"The wrong foreground color!"
);
}
}
}
test/javax/swing/plaf/synth/6771547/synthconfig.xml
0 → 100644
浏览文件 @
8f2e3430
<synth>
<style
id=
"button"
>
<font
name=
"Verdana"
size=
"16"
/>
<state>
<color
value=
"RED"
type=
"javax.swing.plaf.synth.ColorType.FOREGROUND"
/>
</state>
</style>
<bind
style=
"button"
type=
"region"
key=
"button"
/>
</synth>
test/javax/swing/plaf/synth/SynthToolBarUI/6739756/bug6739756.java
0 → 100644
浏览文件 @
8f2e3430
/*
* 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 6739756
* @author Alexander Potochkin
* @summary JToolBar leaves space for non-visible items under Nimbus L&F
* @run main bug6739756
*/
import
javax.swing.*
;
import
java.awt.*
;
public
class
bug6739756
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
try
{
UIManager
.
setLookAndFeel
(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
;
}
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
JToolBar
tb
=
new
JToolBar
();
Dimension
preferredSize
=
tb
.
getPreferredSize
();
JButton
button
=
new
JButton
(
"Test"
);
button
.
setVisible
(
false
);
tb
.
add
(
button
);
if
(!
preferredSize
.
equals
(
tb
.
getPreferredSize
()))
{
throw
new
RuntimeException
(
"Toolbar's preferredSize is wrong"
);
}
}
});
}
}
test/javax/swing/text/DefaultStyledDocument/6636983/bug6636983.java
0 → 100644
浏览文件 @
8f2e3430
/*
* 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 6636983
* @summary test that composed text at the line starts is handled correctly
* @author Sergey Groznyh
* @run main bug6636983
*/
import
sun.swing.SwingUtilities2
;
import
javax.swing.*
;
import
javax.swing.text.*
;
import
javax.swing.text.html.HTMLDocument
;
import
java.awt.*
;
import
java.awt.event.InputMethodEvent
;
import
java.awt.event.KeyEvent
;
import
java.text.AttributedString
;
public
class
bug6636983
{
private
Robot
robot
;
private
final
AttributedString
Hiragana_A
=
new
AttributedString
(
"\u3042"
);
void
sendInputMethodEvent
()
{
InputMethodEvent
ime
=
new
InputMethodEvent
(
ep
,
InputMethodEvent
.
INPUT_METHOD_TEXT_CHANGED
,
Hiragana_A
.
getIterator
(),
0
,
null
,
null
);
ep
.
dispatchEvent
(
ime
);
}
void
checkComposedTextRun
()
{
HTMLDocument
d
=
(
HTMLDocument
)
ep
.
getDocument
();
ElementIterator
it
=
new
ElementIterator
(
d
.
getDefaultRootElement
());
while
(
true
)
{
Element
e
=
it
.
next
();
if
(
e
==
null
)
{
throw
new
RuntimeException
(
"no composed text found"
);
}
AttributeSet
a
=
e
.
getAttributes
();
if
(
a
.
isDefined
(
StyleConstants
.
ComposedTextAttribute
))
{
if
(!
AbstractDocument
.
ContentElementName
.
equals
(
a
.
getAttribute
(
StyleConstants
.
NameAttribute
)))
{
throw
new
RuntimeException
(
"AbstractDocument.ContentElementName.equals(a.getAttribute(StyleConstants.NameAttribute)) is false"
);
}
if
(
a
.
isDefined
(
SwingUtilities2
.
IMPLIED_CR
))
{
throw
new
RuntimeException
(
"a.isDefined(SwingUtilities2.IMPLIED_CR) is true"
);
}
return
;
}
}
}
JEditorPane
ep
;
void
initAtParagraphStart
()
{
ep
.
setText
(
"A<p>B"
);
hitKey
(
KeyEvent
.
VK_LEFT
);
}
void
sendAtParagraphStart
()
{
sendInputMethodEvent
();
}
void
checkAtParagraphStart
()
{
checkComposedTextRun
();
}
void
initAfterBRElement
()
{
ep
.
setText
(
"A<br>B"
);
hitKey
(
KeyEvent
.
VK_LEFT
);
}
void
sendAtBRElement
()
{
sendInputMethodEvent
();
}
void
checkAtBrElement
()
{
checkComposedTextRun
();
}
private
void
hitKey
(
int
keycode
)
{
robot
.
keyPress
(
keycode
);
robot
.
keyRelease
(
keycode
);
robot
.
delay
(
550
);
// The magic number equals JRobot.DEFAULT_DELAY
}
private
void
run
()
throws
Exception
{
robot
=
new
Robot
();
ep
=
new
JEditorPane
();
ep
.
setContentType
(
"text/html"
);
ep
.
setPreferredSize
(
new
Dimension
(
100
,
100
));
JFrame
frame
=
new
JFrame
(
"Test: "
+
getClass
().
getName
());
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
add
(
ep
);
frame
.
setVisible
(
true
);
}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
try
{
bug6636983
bug6636983
=
new
bug6636983
();
bug6636983
.
run
();
bug6636983
.
initAtParagraphStart
();
bug6636983
.
sendAtParagraphStart
();
bug6636983
.
checkAtParagraphStart
();
bug6636983
.
initAfterBRElement
();
bug6636983
.
sendAtBRElement
();
bug6636983
.
checkAtBrElement
();
System
.
out
.
println
(
"OK"
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"The test failed"
,
e
);
}
}
});
}
}
test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java
0 → 100644
浏览文件 @
8f2e3430
/*
* 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.
*/
import
javax.swing.text.*
;
class
StubBranchElement
implements
Element
{
Document
document
=
new
DefaultStyledDocument
();
String
context
;
Element
[]
children
=
new
StubLeafElement
[
3
];
public
StubBranchElement
(
String
context
)
{
this
.
context
=
context
;
int
len
=
context
.
length
()
/
3
;
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
children
[
i
]
=
new
StubLeafElement
(
context
.
substring
(
len
*
i
,
len
*
(
i
+
1
)),
this
,
len
*
i
);
}
try
{
document
.
insertString
(
0
,
context
,
new
SimpleAttributeSet
());
}
catch
(
BadLocationException
e
)
{
}
}
public
Document
getDocument
()
{
return
document
;
}
public
Element
getParentElement
()
{
return
null
;
}
public
String
getName
()
{
return
"StubBranchElement"
;
}
public
AttributeSet
getAttributes
()
{
return
new
SimpleAttributeSet
();
}
public
int
getStartOffset
()
{
return
0
;
}
public
int
getEndOffset
()
{
return
document
.
getLength
();
}
public
int
getElementIndex
(
int
offset
)
{
return
offset
/
3
;
}
public
int
getElementCount
()
{
return
3
;
}
public
Element
getElement
(
int
index
)
{
return
children
[
index
];
}
public
boolean
isLeaf
()
{
return
false
;
}
public
Element
[]
getChildren
()
{
return
children
;
}
}
test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java
0 → 100644
浏览文件 @
8f2e3430
/*
* 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.
*/
import
javax.swing.text.*
;
class
StubLeafElement
implements
Element
{
Document
document
=
new
DefaultStyledDocument
();
String
context
;
Element
parent
;
int
position
;
public
StubLeafElement
(
String
context
,
Element
parent
,
int
position
)
{
this
.
context
=
context
;
this
.
parent
=
parent
;
this
.
position
=
position
;
try
{
document
.
insertString
(
0
,
context
,
new
SimpleAttributeSet
());
}
catch
(
BadLocationException
e
)
{
}
}
public
Document
getDocument
()
{
return
document
;
}
public
Element
getParentElement
()
{
return
parent
;
}
public
String
getName
()
{
return
"StubLeafElement"
;
}
public
AttributeSet
getAttributes
()
{
return
new
SimpleAttributeSet
();
}
public
int
getStartOffset
()
{
return
position
;
}
public
int
getEndOffset
()
{
return
position
+
document
.
getLength
();
}
public
int
getElementIndex
(
int
offset
)
{
return
0
;
}
public
int
getElementCount
()
{
return
0
;
}
public
Element
getElement
(
int
index
)
{
return
this
;
}
public
boolean
isLeaf
()
{
return
true
;
}
}
test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java
0 → 100644
浏览文件 @
8f2e3430
/*
* 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 6857057
* @summary test that the JCK GlyphView2021 test doesn't fail
* @author Sergey Groznyh
* @run main bug6857057
*/
import
javax.swing.*
;
import
javax.swing.text.Element
;
import
javax.swing.text.GlyphView
;
import
javax.swing.text.View
;
public
class
bug6857057
{
bug6857057
()
{
Element
elem
=
new
StubBranchElement
(
" G L Y P H V"
);
GlyphView
view
=
new
GlyphView
(
elem
);
float
pos
=
elem
.
getStartOffset
();
float
len
=
elem
.
getEndOffset
()
-
pos
;
int
res
=
view
.
getBreakWeight
(
View
.
X_AXIS
,
pos
,
len
);
if
(
res
!=
View
.
ExcellentBreakWeight
)
{
throw
new
RuntimeException
(
"breakWeight != ExcellentBreakWeight"
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
new
bug6857057
();
}
});
System
.
out
.
println
(
"OK"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录