Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
55e39e30
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看板
提交
55e39e30
编写于
12月 07, 2011
作者:
A
art
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
Reviewed-by: anthony, denis, bagiras
上级
0c476fef
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
144 addition
and
1094 deletion
+144
-1094
src/share/classes/sun/awt/AWTAutoShutdown.java
src/share/classes/sun/awt/AWTAutoShutdown.java
+8
-3
src/share/classes/sun/awt/AppContext.java
src/share/classes/sun/awt/AppContext.java
+10
-10
src/share/classes/sun/awt/CausedFocusEvent.java
src/share/classes/sun/awt/CausedFocusEvent.java
+1
-0
src/share/classes/sun/awt/DebugSettings.java
src/share/classes/sun/awt/DebugSettings.java
+32
-45
src/share/classes/sun/awt/EmbeddedFrame.java
src/share/classes/sun/awt/EmbeddedFrame.java
+27
-20
src/share/classes/sun/awt/EventListenerAggregate.java
src/share/classes/sun/awt/EventListenerAggregate.java
+5
-10
src/share/classes/sun/awt/FocusingTextField.java
src/share/classes/sun/awt/FocusingTextField.java
+0
-109
src/share/classes/sun/awt/HeadlessToolkit.java
src/share/classes/sun/awt/HeadlessToolkit.java
+3
-0
src/share/classes/sun/awt/HorizBagLayout.java
src/share/classes/sun/awt/HorizBagLayout.java
+0
-154
src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
+3
-1
src/share/classes/sun/awt/ModalityEvent.java
src/share/classes/sun/awt/ModalityEvent.java
+1
-0
src/share/classes/sun/awt/OrientableFlowLayout.java
src/share/classes/sun/awt/OrientableFlowLayout.java
+0
-310
src/share/classes/sun/awt/PaintEventDispatcher.java
src/share/classes/sun/awt/PaintEventDispatcher.java
+1
-1
src/share/classes/sun/awt/PeerEvent.java
src/share/classes/sun/awt/PeerEvent.java
+2
-0
src/share/classes/sun/awt/SunDisplayChanger.java
src/share/classes/sun/awt/SunDisplayChanger.java
+14
-17
src/share/classes/sun/awt/SunGraphicsCallback.java
src/share/classes/sun/awt/SunGraphicsCallback.java
+1
-0
src/share/classes/sun/awt/SunToolkit.java
src/share/classes/sun/awt/SunToolkit.java
+34
-25
src/share/classes/sun/awt/UngrabEvent.java
src/share/classes/sun/awt/UngrabEvent.java
+2
-0
src/share/classes/sun/awt/VariableGridLayout.java
src/share/classes/sun/awt/VariableGridLayout.java
+0
-231
src/share/classes/sun/awt/VerticalBagLayout.java
src/share/classes/sun/awt/VerticalBagLayout.java
+0
-158
未找到文件。
src/share/classes/sun/awt/AWTAutoShutdown.java
浏览文件 @
55e39e30
...
@@ -26,10 +26,13 @@
...
@@ -26,10 +26,13 @@
package
sun.awt
;
package
sun.awt
;
import
java.awt.AWTEvent
;
import
java.awt.AWTEvent
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.IdentityHashMap
;
import
java.util.IdentityHashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
sun.util.logging.PlatformLogger
;
import
sun.util.logging.PlatformLogger
;
/**
/**
...
@@ -81,7 +84,7 @@ public final class AWTAutoShutdown implements Runnable {
...
@@ -81,7 +84,7 @@ public final class AWTAutoShutdown implements Runnable {
* new event to appear in their event queue.
* new event to appear in their event queue.
* Access is synchronized on the main lock object.
* Access is synchronized on the main lock object.
*/
*/
private
final
HashSet
busyThreadSet
=
new
HashSet
(
7
);
private
final
Set
<
Thread
>
busyThreadSet
=
new
HashSet
<>
(
7
);
/**
/**
* Indicates whether the toolkit thread is waiting for a new native
* Indicates whether the toolkit thread is waiting for a new native
...
@@ -93,7 +96,7 @@ public final class AWTAutoShutdown implements Runnable {
...
@@ -93,7 +96,7 @@ public final class AWTAutoShutdown implements Runnable {
* This is a map between components and their peers.
* This is a map between components and their peers.
* we should work with in under activationLock&mainLock lock.
* we should work with in under activationLock&mainLock lock.
*/
*/
private
final
Map
peerMap
=
new
IdentityHashMap
();
private
final
Map
<
Object
,
Object
>
peerMap
=
new
IdentityHashMap
<>
();
/**
/**
* References the alive non-daemon thread that is currently used
* References the alive non-daemon thread that is currently used
...
@@ -319,8 +322,10 @@ public final class AWTAutoShutdown implements Runnable {
...
@@ -319,8 +322,10 @@ public final class AWTAutoShutdown implements Runnable {
}
}
}
}
@SuppressWarnings
(
"serial"
)
static
AWTEvent
getShutdownEvent
()
{
static
AWTEvent
getShutdownEvent
()
{
return
new
AWTEvent
(
getInstance
(),
0
)
{};
return
new
AWTEvent
(
getInstance
(),
0
)
{
};
}
}
/**
/**
...
...
src/share/classes/sun/awt/AppContext.java
浏览文件 @
55e39e30
...
@@ -171,7 +171,7 @@ public final class AppContext {
...
@@ -171,7 +171,7 @@ public final class AppContext {
* HashMap's potentially risky methods, such as clear(), elements(),
* HashMap's potentially risky methods, such as clear(), elements(),
* putAll(), etc.
* putAll(), etc.
*/
*/
private
final
HashMap
table
=
new
HashMap
();
private
final
Map
<
Object
,
Object
>
table
=
new
HashMap
<>
();
private
final
ThreadGroup
threadGroup
;
private
final
ThreadGroup
threadGroup
;
...
@@ -198,8 +198,8 @@ public final class AppContext {
...
@@ -198,8 +198,8 @@ public final class AppContext {
// On the main Thread, we get the ThreadGroup, make a corresponding
// On the main Thread, we get the ThreadGroup, make a corresponding
// AppContext, and instantiate the Java EventQueue. This way, legacy
// AppContext, and instantiate the Java EventQueue. This way, legacy
// code is unaffected by the move to multiple AppContext ability.
// code is unaffected by the move to multiple AppContext ability.
AccessController
.
doPrivileged
(
new
PrivilegedAction
()
{
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>
()
{
public
Object
run
()
{
public
Void
run
()
{
ThreadGroup
currentThreadGroup
=
ThreadGroup
currentThreadGroup
=
Thread
.
currentThread
().
getThreadGroup
();
Thread
.
currentThread
().
getThreadGroup
();
ThreadGroup
parentThreadGroup
=
currentThreadGroup
.
getParent
();
ThreadGroup
parentThreadGroup
=
currentThreadGroup
.
getParent
();
...
@@ -210,7 +210,7 @@ public final class AppContext {
...
@@ -210,7 +210,7 @@ public final class AppContext {
}
}
mainAppContext
=
new
AppContext
(
currentThreadGroup
);
mainAppContext
=
new
AppContext
(
currentThreadGroup
);
numAppContexts
=
1
;
numAppContexts
=
1
;
return
mainAppContext
;
return
null
;
}
}
});
});
}
}
...
@@ -399,8 +399,8 @@ public final class AppContext {
...
@@ -399,8 +399,8 @@ public final class AppContext {
log
.
finer
(
"exception occured while disposing app context"
,
t
);
log
.
finer
(
"exception occured while disposing app context"
,
t
);
}
}
}
}
AccessController
.
doPrivileged
(
new
PrivilegedAction
()
{
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>
()
{
public
Object
run
()
{
public
Void
run
()
{
if
(!
GraphicsEnvironment
.
isHeadless
()
&&
SystemTray
.
isSupported
())
if
(!
GraphicsEnvironment
.
isHeadless
()
&&
SystemTray
.
isSupported
())
{
{
SystemTray
systemTray
=
SystemTray
.
getSystemTray
();
SystemTray
systemTray
=
SystemTray
.
getSystemTray
();
...
@@ -523,7 +523,7 @@ public final class AppContext {
...
@@ -523,7 +523,7 @@ public final class AppContext {
}
}
}
}
static
final
class
CreateThreadAction
implements
PrivilegedAction
{
static
final
class
CreateThreadAction
implements
PrivilegedAction
<
Thread
>
{
private
final
AppContext
appContext
;
private
final
AppContext
appContext
;
private
final
Runnable
runnable
;
private
final
Runnable
runnable
;
...
@@ -532,7 +532,7 @@ public final class AppContext {
...
@@ -532,7 +532,7 @@ public final class AppContext {
runnable
=
r
;
runnable
=
r
;
}
}
public
Object
run
()
{
public
Thread
run
()
{
Thread
t
=
new
Thread
(
appContext
.
getThreadGroup
(),
runnable
);
Thread
t
=
new
Thread
(
appContext
.
getThreadGroup
(),
runnable
);
t
.
setContextClassLoader
(
appContext
.
getContextClassLoader
());
t
.
setContextClassLoader
(
appContext
.
getContextClassLoader
());
t
.
setPriority
(
Thread
.
NORM_PRIORITY
+
1
);
t
.
setPriority
(
Thread
.
NORM_PRIORITY
+
1
);
...
@@ -552,8 +552,8 @@ public final class AppContext {
...
@@ -552,8 +552,8 @@ public final class AppContext {
if
(
appContext
!=
AppContext
.
getAppContext
())
{
if
(
appContext
!=
AppContext
.
getAppContext
())
{
// Create a thread that belongs to the thread group associated
// Create a thread that belongs to the thread group associated
// with the AppContext and invokes EventQueue.postEvent.
// with the AppContext and invokes EventQueue.postEvent.
PrivilegedAction
action
=
new
CreateThreadAction
(
appContext
,
r
);
PrivilegedAction
<
Thread
>
action
=
new
CreateThreadAction
(
appContext
,
r
);
Thread
thread
=
(
Thread
)
AccessController
.
doPrivileged
(
action
);
Thread
thread
=
AccessController
.
doPrivileged
(
action
);
thread
.
start
();
thread
.
start
();
}
else
{
}
else
{
r
.
run
();
r
.
run
();
...
...
src/share/classes/sun/awt/CausedFocusEvent.java
浏览文件 @
55e39e30
...
@@ -35,6 +35,7 @@ import java.awt.Component;
...
@@ -35,6 +35,7 @@ import java.awt.Component;
* CausedFocusEvent class or implicitly, by calling appropriate requestFocusXXX method with "cause"
* CausedFocusEvent class or implicitly, by calling appropriate requestFocusXXX method with "cause"
* parameter. The default cause is UNKNOWN.
* parameter. The default cause is UNKNOWN.
*/
*/
@SuppressWarnings
(
"serial"
)
public
class
CausedFocusEvent
extends
FocusEvent
{
public
class
CausedFocusEvent
extends
FocusEvent
{
public
enum
Cause
{
public
enum
Cause
{
UNKNOWN
,
UNKNOWN
,
...
...
src/share/classes/sun/awt/DebugSettings.java
浏览文件 @
55e39e30
...
@@ -87,9 +87,9 @@ final class DebugSettings {
...
@@ -87,9 +87,9 @@ final class DebugSettings {
};
};
/* global instance of the settings object */
/* global instance of the settings object */
private
static
DebugSettings
instance
=
null
;
private
static
DebugSettings
instance
=
null
;
private
Properties
props
=
new
Properties
();
private
Properties
props
=
new
Properties
();
static
void
init
()
{
static
void
init
()
{
if
(
instance
!=
null
)
{
if
(
instance
!=
null
)
{
...
@@ -102,12 +102,13 @@ final class DebugSettings {
...
@@ -102,12 +102,13 @@ final class DebugSettings {
}
}
private
DebugSettings
()
{
private
DebugSettings
()
{
new
java
.
security
.
PrivilegedAction
()
{
java
.
security
.
AccessController
.
doPrivileged
(
public
Object
run
()
{
new
java
.
security
.
PrivilegedAction
<
Void
>()
{
loadProperties
();
public
Void
run
()
{
return
null
;
loadProperties
();
}
return
null
;
}.
run
();
}
});
}
}
/*
/*
...
@@ -117,15 +118,14 @@ final class DebugSettings {
...
@@ -117,15 +118,14 @@ final class DebugSettings {
private
synchronized
void
loadProperties
()
{
private
synchronized
void
loadProperties
()
{
// setup initial properties
// setup initial properties
java
.
security
.
AccessController
.
doPrivileged
(
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
()
new
java
.
security
.
PrivilegedAction
<
Void
>()
{
{
public
Void
run
()
{
public
Object
run
()
{
loadDefaultProperties
();
loadDefaultProperties
();
loadFileProperties
();
loadFileProperties
();
loadSystemProperties
();
loadSystemProperties
();
return
null
;
return
null
;
}
}
});
});
// echo the initial property settings to stdout
// echo the initial property settings to stdout
if
(
log
.
isLoggable
(
PlatformLogger
.
FINE
))
{
if
(
log
.
isLoggable
(
PlatformLogger
.
FINE
))
{
...
@@ -134,12 +134,9 @@ final class DebugSettings {
...
@@ -134,12 +134,9 @@ final class DebugSettings {
}
}
public
String
toString
()
{
public
String
toString
()
{
Enumeration
enum_
=
props
.
propertyNames
();
ByteArrayOutputStream
bout
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
bout
=
new
ByteArrayOutputStream
();
PrintStream
pout
=
new
PrintStream
(
bout
);
PrintStream
pout
=
new
PrintStream
(
bout
);
for
(
String
key
:
props
.
stringPropertyNames
())
{
while
(
enum_
.
hasMoreElements
())
{
String
key
=
(
String
)
enum_
.
nextElement
();
String
value
=
props
.
getProperty
(
key
,
""
);
String
value
=
props
.
getProperty
(
key
,
""
);
pout
.
println
(
key
+
" = "
+
value
);
pout
.
println
(
key
+
" = "
+
value
);
}
}
...
@@ -198,9 +195,7 @@ final class DebugSettings {
...
@@ -198,9 +195,7 @@ final class DebugSettings {
private
void
loadSystemProperties
()
{
private
void
loadSystemProperties
()
{
// override file properties with system properties
// override file properties with system properties
Properties
sysProps
=
System
.
getProperties
();
Properties
sysProps
=
System
.
getProperties
();
Enumeration
enum_
=
sysProps
.
propertyNames
();
for
(
String
key
:
sysProps
.
stringPropertyNames
())
{
while
(
enum_
.
hasMoreElements
()
)
{
String
key
=
(
String
)
enum_
.
nextElement
();
String
value
=
sysProps
.
getProperty
(
key
,
""
);
String
value
=
sysProps
.
getProperty
(
key
,
""
);
// copy any "awtdebug" properties over
// copy any "awtdebug" properties over
if
(
key
.
startsWith
(
PREFIX
)
)
{
if
(
key
.
startsWith
(
PREFIX
)
)
{
...
@@ -244,17 +239,14 @@ final class DebugSettings {
...
@@ -244,17 +239,14 @@ final class DebugSettings {
return
value
;
return
value
;
}
}
public
synchronized
Enumeration
getPropertyNames
()
{
private
synchronized
List
<
String
>
getPropertyNames
()
{
Vector
propNames
=
new
Vector
();
List
<
String
>
propNames
=
new
LinkedList
<>();
Enumeration
enum_
=
props
.
propertyNames
();
// remove global prefix from property names
// remove global prefix from property names
while
(
enum_
.
hasMoreElements
()
)
{
for
(
String
propName
:
props
.
stringPropertyNames
())
{
String
propName
=
(
String
)
enum_
.
nextElement
();
propName
=
propName
.
substring
(
PREFIX
.
length
()+
1
);
propName
=
propName
.
substring
(
PREFIX
.
length
()+
1
);
propNames
.
add
Element
(
propName
);
propNames
.
add
(
propName
);
}
}
return
propNames
.
elements
()
;
return
propNames
;
}
}
private
void
println
(
Object
object
)
{
private
void
println
(
Object
object
)
{
...
@@ -279,13 +271,11 @@ final class DebugSettings {
...
@@ -279,13 +271,11 @@ final class DebugSettings {
//
//
// Filter out file/line ctrace properties from debug settings
// Filter out file/line ctrace properties from debug settings
//
//
Vector
traces
=
new
Vector
();
List
<
String
>
traces
=
new
LinkedList
<>();
Enumeration
enum_
=
getPropertyNames
();
while
(
enum_
.
hasMoreElements
()
)
{
for
(
String
key
:
getPropertyNames
())
{
String
key
=
(
String
)
enum_
.
nextElement
();
if
(
key
.
startsWith
(
PROP_CTRACE
)
&&
key
.
length
()
>
PROP_CTRACE_LEN
)
{
if
(
key
.
startsWith
(
PROP_CTRACE
)
&&
key
.
length
()
>
PROP_CTRACE_LEN
)
{
traces
.
add
(
key
);
traces
.
addElement
(
key
);
}
}
}
}
...
@@ -295,15 +285,12 @@ final class DebugSettings {
...
@@ -295,15 +285,12 @@ final class DebugSettings {
//
//
// Setup the trace points
// Setup the trace points
//
//
Enumeration
enumTraces
=
traces
.
elements
();
for
(
String
key
:
traces
)
{
String
trace
=
key
.
substring
(
PROP_CTRACE_LEN
+
1
);
while
(
enumTraces
.
hasMoreElements
()
)
{
String
key
=
(
String
)
enumTraces
.
nextElement
();
String
trace
=
key
.
substring
(
PROP_CTRACE_LEN
+
1
);
String
filespec
;
String
filespec
;
String
linespec
;
String
linespec
;
int
delim
=
trace
.
indexOf
(
'@'
);
int
delim
=
trace
.
indexOf
(
'@'
);
boolean
enabled
;
boolean
enabled
;
// parse out the filename and linenumber from the property name
// parse out the filename and linenumber from the property name
filespec
=
delim
!=
-
1
?
trace
.
substring
(
0
,
delim
)
:
trace
;
filespec
=
delim
!=
-
1
?
trace
.
substring
(
0
,
delim
)
:
trace
;
...
...
src/share/classes/sun/awt/EmbeddedFrame.java
浏览文件 @
55e39e30
...
@@ -180,6 +180,7 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -180,6 +180,7 @@ public abstract class EmbeddedFrame extends Frame
* reference to our EmbeddedFrame forever if the Frame is no longer in use, so we
* reference to our EmbeddedFrame forever if the Frame is no longer in use, so we
* add listeners in show() and remove them in hide().
* add listeners in show() and remove them in hide().
*/
*/
@SuppressWarnings
(
"deprecation"
)
public
void
show
()
{
public
void
show
()
{
if
(
appletKFM
!=
null
)
{
if
(
appletKFM
!=
null
)
{
addTraversingOutListeners
(
appletKFM
);
addTraversingOutListeners
(
appletKFM
);
...
@@ -193,6 +194,7 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -193,6 +194,7 @@ public abstract class EmbeddedFrame extends Frame
* reference to our EmbeddedFrame forever if the Frame is no longer in use, so we
* reference to our EmbeddedFrame forever if the Frame is no longer in use, so we
* add listeners in show() and remove them in hide().
* add listeners in show() and remove them in hide().
*/
*/
@SuppressWarnings
(
"deprecation"
)
public
void
hide
()
{
public
void
hide
()
{
if
(
appletKFM
!=
null
)
{
if
(
appletKFM
!=
null
)
{
removeTraversingOutListeners
(
appletKFM
);
removeTraversingOutListeners
(
appletKFM
);
...
@@ -212,8 +214,8 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -212,8 +214,8 @@ public abstract class EmbeddedFrame extends Frame
// belongs to. That's why we can't use public methods to find current focus cycle
// belongs to. That's why we can't use public methods to find current focus cycle
// root. Instead, we access KFM's private field directly.
// root. Instead, we access KFM's private field directly.
if
(
currentCycleRoot
==
null
)
{
if
(
currentCycleRoot
==
null
)
{
currentCycleRoot
=
(
Field
)
AccessController
.
doPrivileged
(
new
PrivilegedAction
()
{
currentCycleRoot
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Field
>
()
{
public
Object
run
()
{
public
Field
run
()
{
try
{
try
{
Field
unaccessibleRoot
=
KeyboardFocusManager
.
class
.
Field
unaccessibleRoot
=
KeyboardFocusManager
.
class
.
getDeclaredField
(
"currentFocusCycleRoot"
);
getDeclaredField
(
"currentFocusCycleRoot"
);
...
@@ -257,7 +259,7 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -257,7 +259,7 @@ public abstract class EmbeddedFrame extends Frame
}
}
AWTKeyStroke
stroke
=
AWTKeyStroke
.
getAWTKeyStrokeForEvent
(
e
);
AWTKeyStroke
stroke
=
AWTKeyStroke
.
getAWTKeyStrokeForEvent
(
e
);
Set
toTest
;
Set
<
AWTKeyStroke
>
toTest
;
Component
currentFocused
=
e
.
getComponent
();
Component
currentFocused
=
e
.
getComponent
();
toTest
=
getFocusTraversalKeys
(
KeyboardFocusManager
.
FORWARD_TRAVERSAL_KEYS
);
toTest
=
getFocusTraversalKeys
(
KeyboardFocusManager
.
FORWARD_TRAVERSAL_KEYS
);
...
@@ -357,6 +359,7 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -357,6 +359,7 @@ public abstract class EmbeddedFrame extends Frame
return
true
;
return
true
;
}
}
@SuppressWarnings
(
"deprecation"
)
public
void
addNotify
()
{
public
void
addNotify
()
{
synchronized
(
getTreeLock
())
{
synchronized
(
getTreeLock
())
{
if
(
getPeer
()
==
null
)
{
if
(
getPeer
()
==
null
)
{
...
@@ -367,6 +370,7 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -367,6 +370,7 @@ public abstract class EmbeddedFrame extends Frame
}
}
// These three functions consitute RFE 4100710. Do not remove.
// These three functions consitute RFE 4100710. Do not remove.
@SuppressWarnings
(
"deprecation"
)
public
void
setCursorAllowed
(
boolean
isCursorAllowed
)
{
public
void
setCursorAllowed
(
boolean
isCursorAllowed
)
{
this
.
isCursorAllowed
=
isCursorAllowed
;
this
.
isCursorAllowed
=
isCursorAllowed
;
getPeer
().
updateCursorImmediately
();
getPeer
().
updateCursorImmediately
();
...
@@ -380,27 +384,28 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -380,27 +384,28 @@ public abstract class EmbeddedFrame extends Frame
:
Cursor
.
getPredefinedCursor
(
Cursor
.
DEFAULT_CURSOR
);
:
Cursor
.
getPredefinedCursor
(
Cursor
.
DEFAULT_CURSOR
);
}
}
protected
void
setPeer
(
final
ComponentPeer
p
){
@SuppressWarnings
(
"deprecation"
)
protected
void
setPeer
(
final
ComponentPeer
p
){
if
(
fieldPeer
==
null
)
{
if
(
fieldPeer
==
null
)
{
fieldPeer
=
(
Field
)
AccessController
.
doPrivileged
(
new
PrivilegedAction
()
{
fieldPeer
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Field
>()
{
public
Object
run
()
{
public
Field
run
()
{
try
{
try
{
Field
lnkPeer
=
Component
.
class
.
getDeclaredField
(
"peer"
);
Field
lnkPeer
=
Component
.
class
.
getDeclaredField
(
"peer"
);
if
(
lnkPeer
!=
null
)
{
if
(
lnkPeer
!=
null
)
{
lnkPeer
.
setAccessible
(
true
);
lnkPeer
.
setAccessible
(
true
);
}
return
lnkPeer
;
}
catch
(
NoSuchFieldException
e
)
{
assert
false
;
}
catch
(
SecurityException
e
)
{
assert
false
;
}
}
return
null
;
return
lnkPeer
;
}
//run
}
catch
(
NoSuchFieldException
e
)
{
});
assert
false
;
}
catch
(
SecurityException
e
)
{
assert
false
;
}
return
null
;
}
//run
});
}
}
try
{
try
{
if
(
fieldPeer
!=
null
){
if
(
fieldPeer
!=
null
){
fieldPeer
.
set
(
EmbeddedFrame
.
this
,
p
);
fieldPeer
.
set
(
EmbeddedFrame
.
this
,
p
);
}
}
}
catch
(
IllegalAccessException
e
)
{
}
catch
(
IllegalAccessException
e
)
{
...
@@ -507,6 +512,7 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -507,6 +512,7 @@ public abstract class EmbeddedFrame extends Frame
* @see #getBoundsPrivate
* @see #getBoundsPrivate
* @since 1.5
* @since 1.5
*/
*/
@SuppressWarnings
(
"deprecation"
)
protected
void
setBoundsPrivate
(
int
x
,
int
y
,
int
width
,
int
height
)
{
protected
void
setBoundsPrivate
(
int
x
,
int
y
,
int
width
,
int
height
)
{
final
FramePeer
peer
=
(
FramePeer
)
getPeer
();
final
FramePeer
peer
=
(
FramePeer
)
getPeer
();
if
(
peer
!=
null
)
{
if
(
peer
!=
null
)
{
...
@@ -538,6 +544,7 @@ public abstract class EmbeddedFrame extends Frame
...
@@ -538,6 +544,7 @@ public abstract class EmbeddedFrame extends Frame
* @see #setBoundsPrivate
* @see #setBoundsPrivate
* @since 1.6
* @since 1.6
*/
*/
@SuppressWarnings
(
"deprecation"
)
protected
Rectangle
getBoundsPrivate
()
{
protected
Rectangle
getBoundsPrivate
()
{
final
FramePeer
peer
=
(
FramePeer
)
getPeer
();
final
FramePeer
peer
=
(
FramePeer
)
getPeer
();
if
(
peer
!=
null
)
{
if
(
peer
!=
null
)
{
...
...
src/share/classes/sun/awt/EventListenerAggregate.java
浏览文件 @
55e39e30
...
@@ -53,20 +53,15 @@ public class EventListenerAggregate {
...
@@ -53,20 +53,15 @@ public class EventListenerAggregate {
* @throws ClassCastException if <code>listenerClass</code> is not
* @throws ClassCastException if <code>listenerClass</code> is not
* assignable to <code>java.util.EventListener</code>
* assignable to <code>java.util.EventListener</code>
*/
*/
public
EventListenerAggregate
(
Class
listenerClass
)
{
public
EventListenerAggregate
(
Class
<?
extends
EventListener
>
listenerClass
)
{
if
(
listenerClass
==
null
)
{
if
(
listenerClass
==
null
)
{
throw
new
NullPointerException
(
"listener class is null"
);
throw
new
NullPointerException
(
"listener class is null"
);
}
}
if
(!
EventListener
.
class
.
isAssignableFrom
(
listenerClass
))
{
throw
new
ClassCastException
(
"listener class "
+
listenerClass
+
" is not assignable to EventListener"
);
}
listenerList
=
(
EventListener
[])
Array
.
newInstance
(
listenerClass
,
0
);
listenerList
=
(
EventListener
[])
Array
.
newInstance
(
listenerClass
,
0
);
}
}
private
Class
getListenerClass
()
{
private
Class
<?>
getListenerClass
()
{
return
listenerList
.
getClass
().
getComponentType
();
return
listenerList
.
getClass
().
getComponentType
();
}
}
...
@@ -80,7 +75,7 @@ public class EventListenerAggregate {
...
@@ -80,7 +75,7 @@ public class EventListenerAggregate {
* in the constructor
* in the constructor
*/
*/
public
synchronized
void
add
(
EventListener
listener
)
{
public
synchronized
void
add
(
EventListener
listener
)
{
Class
listenerClass
=
getListenerClass
();
Class
<?>
listenerClass
=
getListenerClass
();
if
(!
listenerClass
.
isInstance
(
listener
))
{
// null is not an instance of any class
if
(!
listenerClass
.
isInstance
(
listener
))
{
// null is not an instance of any class
throw
new
ClassCastException
(
"listener "
+
listener
+
" is not "
+
throw
new
ClassCastException
(
"listener "
+
listener
+
" is not "
+
...
@@ -107,7 +102,7 @@ public class EventListenerAggregate {
...
@@ -107,7 +102,7 @@ public class EventListenerAggregate {
* in the constructor
* in the constructor
*/
*/
public
synchronized
boolean
remove
(
EventListener
listener
)
{
public
synchronized
boolean
remove
(
EventListener
listener
)
{
Class
listenerClass
=
getListenerClass
();
Class
<?>
listenerClass
=
getListenerClass
();
if
(!
listenerClass
.
isInstance
(
listener
))
{
// null is not an instance of any class
if
(!
listenerClass
.
isInstance
(
listener
))
{
// null is not an instance of any class
throw
new
ClassCastException
(
"listener "
+
listener
+
" is not "
+
throw
new
ClassCastException
(
"listener "
+
listener
+
" is not "
+
...
@@ -155,7 +150,7 @@ public class EventListenerAggregate {
...
@@ -155,7 +150,7 @@ public class EventListenerAggregate {
* array if there are no listeners)
* array if there are no listeners)
*/
*/
public
synchronized
EventListener
[]
getListenersCopy
()
{
public
synchronized
EventListener
[]
getListenersCopy
()
{
return
(
listenerList
.
length
==
0
)
?
listenerList
:
(
EventListener
[])
listenerList
.
clone
();
return
(
listenerList
.
length
==
0
)
?
listenerList
:
listenerList
.
clone
();
}
}
/**
/**
...
...
src/share/classes/sun/awt/FocusingTextField.java
已删除
100644 → 0
浏览文件 @
0c476fef
/*
* Copyright (c) 1995, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
sun.awt
;
import
java.awt.*
;
/**
* FocusingTextField: a subclass of java.awt.TextField that handles moving the
* input focus from field to field, as when the user hits 'return.'
*
* @author Herb Jellinek
*/
public
class
FocusingTextField
extends
TextField
{
/** The field to move to on 'return' - can be null. */
TextField
next
;
/** If true, select the contents of the field when it gets the focus. */
boolean
willSelect
;
/**
* Create a FocusingTextField.
* @param cols number of columns of text.
*/
public
FocusingTextField
(
int
cols
)
{
super
(
""
,
cols
);
}
/**
* Create a FocusingTextField.
* @param cols number of columns of text.
* @param willSelect if true, will select all contents of field when
* focus is gained.
*/
public
FocusingTextField
(
int
cols
,
boolean
willSelect
)
{
this
(
cols
);
this
.
willSelect
=
willSelect
;
}
public
void
setWillSelect
(
boolean
will
)
{
willSelect
=
will
;
}
public
boolean
getWillSelect
()
{
return
willSelect
;
}
/**
* Call this to set the next field to receive the input focus.
* @param next the next TextField in order - can be null.
*/
public
void
setNextField
(
TextField
next
)
{
this
.
next
=
next
;
}
/**
* We got the focus. If willSelect is true, select everything.
*/
public
boolean
gotFocus
(
Event
e
,
Object
arg
)
{
if
(
willSelect
)
{
select
(
0
,
getText
().
length
());
}
return
true
;
}
/**
* We lost the focus. If willSelect is true, deselect everything.
*/
public
boolean
lostFocus
(
Event
e
,
Object
arg
)
{
if
(
willSelect
)
{
select
(
0
,
0
);
}
return
true
;
}
/**
* Pass the focus to the next guy, if any.
*/
public
void
nextFocus
()
{
if
(
next
!=
null
)
{
next
.
requestFocus
();
}
super
.
nextFocus
();
}
}
src/share/classes/sun/awt/HeadlessToolkit.java
浏览文件 @
55e39e30
...
@@ -396,6 +396,7 @@ public class HeadlessToolkit extends Toolkit
...
@@ -396,6 +396,7 @@ public class HeadlessToolkit extends Toolkit
/*
/*
* Fonts
* Fonts
*/
*/
@SuppressWarnings
(
"deprecation"
)
public
FontPeer
getFontPeer
(
String
name
,
int
style
)
{
public
FontPeer
getFontPeer
(
String
name
,
int
style
)
{
if
(
componentFactory
!=
null
)
{
if
(
componentFactory
!=
null
)
{
return
componentFactory
.
getFontPeer
(
name
,
style
);
return
componentFactory
.
getFontPeer
(
name
,
style
);
...
@@ -403,10 +404,12 @@ public class HeadlessToolkit extends Toolkit
...
@@ -403,10 +404,12 @@ public class HeadlessToolkit extends Toolkit
return
null
;
return
null
;
}
}
@SuppressWarnings
(
"deprecation"
)
public
FontMetrics
getFontMetrics
(
Font
font
)
{
public
FontMetrics
getFontMetrics
(
Font
font
)
{
return
tk
.
getFontMetrics
(
font
);
return
tk
.
getFontMetrics
(
font
);
}
}
@SuppressWarnings
(
"deprecation"
)
public
String
[]
getFontList
()
{
public
String
[]
getFontList
()
{
return
tk
.
getFontList
();
return
tk
.
getFontList
();
}
}
...
...
src/share/classes/sun/awt/HorizBagLayout.java
已删除
100644 → 0
浏览文件 @
0c476fef
/*
* Copyright (c) 1995, 2007, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
sun.awt
;
import
java.awt.*
;
/**
* A horizontal 'bag' of Components. Allocates space for each Component
* from left to right.
*
* @author Herb Jellinek
*/
public
class
HorizBagLayout
implements
LayoutManager
{
int
hgap
;
/**
* Constructs a new HorizBagLayout.
*/
public
HorizBagLayout
()
{
this
(
0
);
}
/**
* Constructs a HorizBagLayout with the specified gaps.
* @param hgap the horizontal gap
*/
public
HorizBagLayout
(
int
hgap
)
{
this
.
hgap
=
hgap
;
}
/**
* Adds the specified named component to the layout.
* @param name the String name
* @param comp the component to be added
*/
public
void
addLayoutComponent
(
String
name
,
Component
comp
)
{
}
/**
* Removes the specified component from the layout.
* @param comp the component to be removed
*/
public
void
removeLayoutComponent
(
Component
comp
)
{
}
/**
* Returns the minimum dimensions needed to lay out the components
* contained in the specified target container.
* @param target the Container on which to do the layout
* @see Container
* @see #preferredLayoutSize
*/
public
Dimension
minimumLayoutSize
(
Container
target
)
{
Dimension
dim
=
new
Dimension
();
for
(
int
i
=
0
;
i
<
target
.
countComponents
();
i
++)
{
Component
comp
=
target
.
getComponent
(
i
);
if
(
comp
.
isVisible
())
{
Dimension
d
=
comp
.
minimumSize
();
dim
.
width
+=
d
.
width
+
hgap
;
dim
.
height
=
Math
.
max
(
d
.
height
,
dim
.
height
);
}
}
Insets
insets
=
target
.
insets
();
dim
.
width
+=
insets
.
left
+
insets
.
right
;
dim
.
height
+=
insets
.
top
+
insets
.
bottom
;
return
dim
;
}
/**
* Returns the preferred dimensions for this layout given the components
* in the specified target container.
* @param target the component which needs to be laid out
* @see Container
* @see #minimumLayoutSize
*/
public
Dimension
preferredLayoutSize
(
Container
target
)
{
Dimension
dim
=
new
Dimension
();
for
(
int
i
=
0
;
i
<
target
.
countComponents
();
i
++)
{
Component
comp
=
target
.
getComponent
(
i
);
if
(
comp
.
isVisible
())
{
Dimension
d
=
comp
.
preferredSize
();
dim
.
width
+=
d
.
width
+
hgap
;
dim
.
height
=
Math
.
max
(
dim
.
height
,
d
.
height
);
}
}
Insets
insets
=
target
.
insets
();
dim
.
width
+=
insets
.
left
+
insets
.
right
;
dim
.
height
+=
insets
.
top
+
insets
.
bottom
;
return
dim
;
}
/**
* Lays out the specified container. This method will actually reshape the
* components in the specified target container in order to satisfy the
* constraints of the HorizBagLayout object.
* @param target the component being laid out
* @see Container
*/
public
void
layoutContainer
(
Container
target
)
{
Insets
insets
=
target
.
insets
();
int
top
=
insets
.
top
;
int
bottom
=
target
.
size
().
height
-
insets
.
bottom
;
int
left
=
insets
.
left
;
int
right
=
target
.
size
().
width
-
insets
.
right
;
for
(
int
i
=
0
;
i
<
target
.
countComponents
();
i
++)
{
Component
comp
=
target
.
getComponent
(
i
);
if
(
comp
.
isVisible
())
{
int
compWidth
=
comp
.
size
().
width
;
comp
.
resize
(
compWidth
,
bottom
-
top
);
Dimension
d
=
comp
.
preferredSize
();
comp
.
reshape
(
left
,
top
,
d
.
width
,
bottom
-
top
);
left
+=
d
.
width
+
hgap
;
}
}
}
/**
* Returns the String representation of this HorizBagLayout's values.
*/
public
String
toString
()
{
return
getClass
().
getName
()
+
"[hgap="
+
hgap
+
"]"
;
}
}
src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
浏览文件 @
55e39e30
...
@@ -80,6 +80,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
...
@@ -80,6 +80,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
* 1) accepts focus on click (in general)
* 1) accepts focus on click (in general)
* 2) may be a focus owner (in particular)
* 2) may be a focus owner (in particular)
*/
*/
@SuppressWarnings
(
"deprecation"
)
public
static
boolean
shouldFocusOnClick
(
Component
component
)
{
public
static
boolean
shouldFocusOnClick
(
Component
component
)
{
boolean
acceptFocusOnClick
=
false
;
boolean
acceptFocusOnClick
=
false
;
...
@@ -110,6 +111,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
...
@@ -110,6 +111,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
/*
/*
* Posts proper lost/gain focus events to the event queue.
* Posts proper lost/gain focus events to the event queue.
*/
*/
@SuppressWarnings
(
"deprecation"
)
public
static
boolean
deliverFocus
(
Component
lightweightChild
,
public
static
boolean
deliverFocus
(
Component
lightweightChild
,
Component
target
,
Component
target
,
boolean
temporary
,
boolean
temporary
,
...
@@ -119,7 +121,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
...
@@ -119,7 +121,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
Component
currentFocusOwner
)
// provided by the descendant peers
Component
currentFocusOwner
)
// provided by the descendant peers
{
{
if
(
lightweightChild
==
null
)
{
if
(
lightweightChild
==
null
)
{
lightweightChild
=
(
Component
)
target
;
lightweightChild
=
target
;
}
}
Component
currentOwner
=
currentFocusOwner
;
Component
currentOwner
=
currentFocusOwner
;
...
...
src/share/classes/sun/awt/ModalityEvent.java
浏览文件 @
55e39e30
...
@@ -30,6 +30,7 @@ import java.awt.*;
...
@@ -30,6 +30,7 @@ import java.awt.*;
/**
/**
* Event object describing changes in AWT modality
* Event object describing changes in AWT modality
*/
*/
@SuppressWarnings
(
"serial"
)
public
class
ModalityEvent
extends
AWTEvent
implements
ActiveEvent
{
public
class
ModalityEvent
extends
AWTEvent
implements
ActiveEvent
{
public
static
final
int
MODALITY_PUSHED
=
1300
;
public
static
final
int
MODALITY_PUSHED
=
1300
;
...
...
src/share/classes/sun/awt/OrientableFlowLayout.java
已删除
100644 → 0
浏览文件 @
0c476fef
/*
* Copyright (c) 1996, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
sun.awt
;
import
java.awt.*
;
/**
* Extends the FlowLayout class to support both vertical and horizontal
* layout of components. Orientation can be changed dynamically after
* creation by calling either of the methods @method orientHorizontally or
* @method orientVertically. Separate values for alignment, vertical gap,
* and horizontal gap can be specified for horizontal and vertical
* orientation.
*
* @author Terry Cline
*/
public
class
OrientableFlowLayout
extends
FlowLayout
{
/**
* The horizontal orientation constant.
*/
public
static
final
int
HORIZONTAL
=
0
;
/**
* The vertical orientation constant.
*/
public
static
final
int
VERTICAL
=
1
;
/**
* The top vertical alignment constant.
*/
public
static
final
int
TOP
=
0
;
/**
* The bottom vertical alignment constant.
*/
public
static
final
int
BOTTOM
=
2
;
// CENTER == 1
int
orientation
;
int
vAlign
;
int
vHGap
;
int
vVGap
;
/**
* Constructs a new flow layout with a horizontal orientation and
* centered alignment.
*/
public
OrientableFlowLayout
()
{
this
(
HORIZONTAL
,
CENTER
,
CENTER
,
5
,
5
,
5
,
5
);
}
/**
* Constructs a new flow layout with the specified orientation and
* a centered alignment.
*
* @param orientation the orientation, one of HORIZONTAL or VERTICAL.
*/
public
OrientableFlowLayout
(
int
orientation
)
{
this
(
orientation
,
CENTER
,
CENTER
,
5
,
5
,
5
,
5
);
}
/**
* Constructs a new flow layout with the specified orientation and
* alignment.
*
* @param orientation the orientation, one of HORIZONTAL or VERTICAL.
* @param hAlign the horizontal alignment, one of LEFT, CENTER, or RIGHT.
* @param vAlign the vertical alignment, one of TOP, CENTER, or BOTTOM.
*/
public
OrientableFlowLayout
(
int
orientation
,
int
hAlign
,
int
vAlign
)
{
this
(
orientation
,
hAlign
,
vAlign
,
5
,
5
,
5
,
5
);
}
/**
* Constructs a new flow layout with the specified orientation,
* alignment, and gap values.
*
* @param orientation the orientation, one of HORIZONTAL or VERTICAL.
* @param hAlign the horizontal alignment, one of LEFT, CENTER, or RIGHT.
* @param vAlign the vertical alignment, one of TOP, CENTER, or BOTTOM.
* @param hHGap the horizontal gap between components in HORIZONTAL.
* @param hVGap the vertical gap between components in HORIZONTAL.
* @param vHGap the horizontal gap between components in VERTICAL.
* @param vVGap the vertical gap between components in VERTICAL.
*/
public
OrientableFlowLayout
(
int
orientation
,
int
hAlign
,
int
vAlign
,
int
hHGap
,
int
hVGap
,
int
vHGap
,
int
vVGap
)
{
super
(
hAlign
,
hHGap
,
hVGap
);
this
.
orientation
=
orientation
;
this
.
vAlign
=
vAlign
;
this
.
vHGap
=
vHGap
;
this
.
vVGap
=
vVGap
;
}
/**
* Set the layout's current orientation to horizontal.
*/
public
synchronized
void
orientHorizontally
()
{
orientation
=
HORIZONTAL
;
}
/**
* Set the layout's current orientation to vertical.
*/
public
synchronized
void
orientVertically
()
{
orientation
=
VERTICAL
;
}
/**
* Returns the preferred dimensions for this layout given the
* components in the specified target container.
*
* @param target the component which needs to be laid out.
* @see Container
* @see FlowLayout
* @see #minimumLayoutSize
*/
public
Dimension
preferredLayoutSize
(
Container
target
)
{
if
(
orientation
==
HORIZONTAL
)
{
return
super
.
preferredLayoutSize
(
target
);
}
else
{
Dimension
dim
=
new
Dimension
(
0
,
0
);
int
n
=
target
.
countComponents
();
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
Component
c
=
target
.
getComponent
(
i
);
if
(
c
.
isVisible
())
{
Dimension
cDim
=
c
.
preferredSize
();
dim
.
width
=
Math
.
max
(
dim
.
width
,
cDim
.
width
);
if
(
i
>
0
)
{
dim
.
height
+=
vVGap
;
}
dim
.
height
+=
cDim
.
height
;
}
}
Insets
insets
=
target
.
insets
();;
dim
.
width
+=
insets
.
left
+
insets
.
right
+
vHGap
*
2
;
dim
.
height
+=
insets
.
top
+
insets
.
bottom
+
vVGap
*
2
;
return
dim
;
}
}
/**
* Returns the minimum dimensions needed to layout the components
* contained in the specified target container.
*
* @param target the component which needs to be laid out.
* @see #preferredLayoutSize.
*/
public
Dimension
minimumLayoutSize
(
Container
target
)
{
if
(
orientation
==
HORIZONTAL
)
{
return
super
.
minimumLayoutSize
(
target
);
}
else
{
Dimension
dim
=
new
Dimension
(
0
,
0
);
int
n
=
target
.
countComponents
();
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
Component
c
=
target
.
getComponent
(
i
);
if
(
c
.
isVisible
())
{
Dimension
cDim
=
c
.
minimumSize
();
dim
.
width
=
Math
.
max
(
dim
.
width
,
cDim
.
width
);
if
(
i
>
0
)
{
dim
.
height
+=
vVGap
;
}
dim
.
height
+=
cDim
.
height
;
}
}
Insets
insets
=
target
.
insets
();
dim
.
width
+=
insets
.
left
+
insets
.
right
+
vHGap
*
2
;
dim
.
height
+=
insets
.
top
+
insets
.
bottom
+
vVGap
*
2
;
return
dim
;
}
}
/**
* Lays out the container. This method will reshape the
* components in the target to satisfy the constraints of the
* layout.
*
* @param target the specified component being laid out.
* @see Container.
*/
public
void
layoutContainer
(
Container
target
)
{
if
(
orientation
==
HORIZONTAL
)
{
super
.
layoutContainer
(
target
);
}
else
{
Insets
insets
=
target
.
insets
();
Dimension
targetDim
=
target
.
size
();
int
maxHeight
=
targetDim
.
height
-
(
insets
.
top
+
insets
.
bottom
+
vVGap
*
2
);
int
x
=
insets
.
left
+
vHGap
;
int
y
=
0
;
int
colWidth
=
0
;
int
start
=
0
;
int
n
=
target
.
countComponents
();
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
Component
c
=
target
.
getComponent
(
i
);
if
(
c
.
isVisible
())
{
Dimension
cDim
=
c
.
preferredSize
();
c
.
resize
(
cDim
.
width
,
cDim
.
height
);
if
((
y
==
0
)
||
((
y
+
cDim
.
height
)
<=
maxHeight
))
{
if
(
y
>
0
)
{
y
+=
vVGap
;
}
y
+=
cDim
.
height
;
colWidth
=
Math
.
max
(
colWidth
,
cDim
.
width
);
}
else
{
moveComponents
(
target
,
x
,
insets
.
top
+
vVGap
,
colWidth
,
maxHeight
-
y
,
start
,
i
);
x
+=
vHGap
+
colWidth
;
y
=
cDim
.
width
;
colWidth
=
cDim
.
width
;
start
=
i
;
}
}
}
moveComponents
(
target
,
x
,
insets
.
top
+
vVGap
,
colWidth
,
maxHeight
-
y
,
start
,
n
);
}
}
/**
* Aligns the components vertically if there is any slack.
*
* @param target the container whose components need to be moved.
* @param x the x coordinate.
* @param y the y coordinate.
* @param width the width available.
* @param height the height available.
* @param colStart the beginning of the column.
* @param colEnd the end of the column.
*/
private
void
moveComponents
(
Container
target
,
int
x
,
int
y
,
int
width
,
int
height
,
int
colStart
,
int
colEnd
)
{
switch
(
vAlign
)
{
case
TOP:
break
;
case
CENTER:
y
+=
height
/
2
;
break
;
case
BOTTOM:
y
+=
height
;
}
for
(
int
i
=
colStart
;
i
<
colEnd
;
i
++)
{
Component
c
=
target
.
getComponent
(
i
);
Dimension
cDim
=
c
.
size
();
if
(
c
.
isVisible
())
{
c
.
move
(
x
+
(
width
-
cDim
.
width
)/
2
,
y
);
y
+=
vVGap
+
cDim
.
height
;
}
}
}
/**
* Returns the String representation of this layout's values.
*/
public
String
toString
()
{
String
str
=
""
;
switch
(
orientation
)
{
case
HORIZONTAL:
str
=
"orientation=horizontal, "
;
break
;
case
VERTICAL:
str
=
"orientation=vertical, "
;
break
;
}
return
getClass
().
getName
()
+
"["
+
str
+
super
.
toString
()
+
"]"
;
}
}
src/share/classes/sun/awt/PaintEventDispatcher.java
浏览文件 @
55e39e30
...
@@ -77,7 +77,7 @@ public class PaintEventDispatcher {
...
@@ -77,7 +77,7 @@ public class PaintEventDispatcher {
public
PaintEvent
createPaintEvent
(
Component
target
,
int
x
,
int
y
,
int
w
,
public
PaintEvent
createPaintEvent
(
Component
target
,
int
x
,
int
y
,
int
w
,
int
h
)
{
int
h
)
{
return
new
PaintEvent
(
(
Component
)
target
,
PaintEvent
.
PAINT
,
return
new
PaintEvent
(
target
,
PaintEvent
.
PAINT
,
new
Rectangle
(
x
,
y
,
w
,
h
));
new
Rectangle
(
x
,
y
,
w
,
h
));
}
}
...
...
src/share/classes/sun/awt/PeerEvent.java
浏览文件 @
55e39e30
...
@@ -27,7 +27,9 @@ package sun.awt;
...
@@ -27,7 +27,9 @@ package sun.awt;
import
java.awt.event.InvocationEvent
;
import
java.awt.event.InvocationEvent
;
@SuppressWarnings
(
"serial"
)
public
class
PeerEvent
extends
InvocationEvent
{
public
class
PeerEvent
extends
InvocationEvent
{
public
static
final
long
PRIORITY_EVENT
=
0x01
;
public
static
final
long
PRIORITY_EVENT
=
0x01
;
public
static
final
long
ULTIMATE_PRIORITY_EVENT
=
0x02
;
public
static
final
long
ULTIMATE_PRIORITY_EVENT
=
0x02
;
public
static
final
long
LOW_PRIORITY_EVENT
=
0x04
;
public
static
final
long
LOW_PRIORITY_EVENT
=
0x04
;
...
...
src/share/classes/sun/awt/SunDisplayChanger.java
浏览文件 @
55e39e30
...
@@ -28,9 +28,10 @@ package sun.awt;
...
@@ -28,9 +28,10 @@ package sun.awt;
import
java.awt.IllegalComponentStateException
;
import
java.awt.IllegalComponentStateException
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.HashMap
;
import
java.util.WeakHashMap
;
import
java.util.WeakHashMap
;
import
sun.util.logging.PlatformLogger
;
import
sun.util.logging.PlatformLogger
;
...
@@ -54,12 +55,14 @@ import sun.util.logging.PlatformLogger;
...
@@ -54,12 +55,14 @@ import sun.util.logging.PlatformLogger;
* screen to another on a system equipped with multiple displays.
* screen to another on a system equipped with multiple displays.
*/
*/
public
class
SunDisplayChanger
{
public
class
SunDisplayChanger
{
private
static
final
PlatformLogger
log
=
PlatformLogger
.
getLogger
(
"sun.awt.multiscreen.SunDisplayChanger"
);
private
static
final
PlatformLogger
log
=
PlatformLogger
.
getLogger
(
"sun.awt.multiscreen.SunDisplayChanger"
);
// Create a new synchronized
M
ap with initial capacity of one listener.
// Create a new synchronized
m
ap with initial capacity of one listener.
// It is asserted that the most common case is to have one GraphicsDevice
// It is asserted that the most common case is to have one GraphicsDevice
// and one top-level Window.
// and one top-level Window.
private
Map
listeners
=
Collections
.
synchronizedMap
(
new
WeakHashMap
(
1
));
private
Map
<
DisplayChangedListener
,
Void
>
listeners
=
Collections
.
synchronizedMap
(
new
WeakHashMap
<
DisplayChangedListener
,
Void
>(
1
));
public
SunDisplayChanger
()
{}
public
SunDisplayChanger
()
{}
...
@@ -113,18 +116,15 @@ public class SunDisplayChanger {
...
@@ -113,18 +116,15 @@ public class SunDisplayChanger {
// synchronization provides no protection against modifying the listener
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
// list while in the middle of iterating over it. -bchristi 7/10/2001
HashMap
listClone
;
Set
<
DisplayChangedListener
>
cloneSet
;
Set
cloneSet
;
synchronized
(
listeners
)
{
synchronized
(
listeners
)
{
listClone
=
new
HashMap
(
listeners
);
cloneSet
=
new
HashSet
<
DisplayChangedListener
>(
listeners
.
keySet
()
);
}
}
cloneSet
=
listClone
.
keySet
();
Iterator
<
DisplayChangedListener
>
itr
=
cloneSet
.
iterator
();
Iterator
itr
=
cloneSet
.
iterator
();
while
(
itr
.
hasNext
())
{
while
(
itr
.
hasNext
())
{
DisplayChangedListener
current
=
DisplayChangedListener
current
=
itr
.
next
();
(
DisplayChangedListener
)
itr
.
next
();
try
{
try
{
if
(
log
.
isLoggable
(
PlatformLogger
.
FINEST
))
{
if
(
log
.
isLoggable
(
PlatformLogger
.
FINEST
))
{
log
.
finest
(
"displayChanged for listener: "
+
current
);
log
.
finest
(
"displayChanged for listener: "
+
current
);
...
@@ -160,17 +160,14 @@ public class SunDisplayChanger {
...
@@ -160,17 +160,14 @@ public class SunDisplayChanger {
// synchronization provides no protection against modifying the listener
// synchronization provides no protection against modifying the listener
// list while in the middle of iterating over it. -bchristi 7/10/2001
// list while in the middle of iterating over it. -bchristi 7/10/2001
HashMap
listClone
;
Set
<
DisplayChangedListener
>
cloneSet
;
Set
cloneSet
;
synchronized
(
listeners
)
{
synchronized
(
listeners
)
{
listClone
=
new
HashMap
(
listeners
);
cloneSet
=
new
HashSet
<
DisplayChangedListener
>(
listeners
.
keySet
()
);
}
}
cloneSet
=
listClone
.
keySet
();
Iterator
<
DisplayChangedListener
>
itr
=
cloneSet
.
iterator
();
Iterator
itr
=
cloneSet
.
iterator
();
while
(
itr
.
hasNext
())
{
while
(
itr
.
hasNext
())
{
DisplayChangedListener
current
=
DisplayChangedListener
current
=
itr
.
next
();
(
DisplayChangedListener
)
itr
.
next
();
try
{
try
{
if
(
log
.
isLoggable
(
PlatformLogger
.
FINEST
))
{
if
(
log
.
isLoggable
(
PlatformLogger
.
FINEST
))
{
log
.
finest
(
"paletteChanged for listener: "
+
current
);
log
.
finest
(
"paletteChanged for listener: "
+
current
);
...
...
src/share/classes/sun/awt/SunGraphicsCallback.java
浏览文件 @
55e39e30
...
@@ -47,6 +47,7 @@ public abstract class SunGraphicsCallback {
...
@@ -47,6 +47,7 @@ public abstract class SunGraphicsCallback {
g
.
clipRect
(
0
,
0
,
bounds
.
width
,
bounds
.
height
);
g
.
clipRect
(
0
,
0
,
bounds
.
width
,
bounds
.
height
);
}
}
@SuppressWarnings
(
"deprecation"
)
public
final
void
runOneComponent
(
Component
comp
,
Rectangle
bounds
,
public
final
void
runOneComponent
(
Component
comp
,
Rectangle
bounds
,
Graphics
g
,
Shape
clip
,
Graphics
g
,
Shape
clip
,
int
weightFlags
)
{
int
weightFlags
)
{
...
...
src/share/classes/sun/awt/SunToolkit.java
浏览文件 @
55e39e30
...
@@ -197,6 +197,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -197,6 +197,7 @@ public abstract class SunToolkit extends Toolkit
public
abstract
boolean
isTraySupported
();
public
abstract
boolean
isTraySupported
();
@SuppressWarnings
(
"deprecation"
)
public
abstract
FontPeer
getFontPeer
(
String
name
,
int
style
);
public
abstract
FontPeer
getFontPeer
(
String
name
,
int
style
);
public
abstract
RobotPeer
createRobot
(
Robot
target
,
GraphicsDevice
screen
)
public
abstract
RobotPeer
createRobot
(
Robot
target
,
GraphicsDevice
screen
)
...
@@ -305,7 +306,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -305,7 +306,7 @@ public abstract class SunToolkit extends Toolkit
return
appContext
;
return
appContext
;
}
}
public
static
Field
getField
(
final
Class
klass
,
final
String
fieldName
)
{
public
static
Field
getField
(
final
Class
<?>
klass
,
final
String
fieldName
)
{
return
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Field
>()
{
return
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Field
>()
{
public
Field
run
()
{
public
Field
run
()
{
try
{
try
{
...
@@ -325,8 +326,8 @@ public abstract class SunToolkit extends Toolkit
...
@@ -325,8 +326,8 @@ public abstract class SunToolkit extends Toolkit
static
void
wakeupEventQueue
(
EventQueue
q
,
boolean
isShutdown
){
static
void
wakeupEventQueue
(
EventQueue
q
,
boolean
isShutdown
){
if
(
wakeupMethod
==
null
){
if
(
wakeupMethod
==
null
){
wakeupMethod
=
(
Method
)
AccessController
.
doPrivileged
(
new
PrivilegedAction
()
{
wakeupMethod
=
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Method
>()
{
public
Object
run
()
{
public
Method
run
()
{
try
{
try
{
Method
method
=
EventQueue
.
class
.
getDeclaredMethod
(
"wakeup"
,
new
Class
[]
{
Boolean
.
TYPE
}
);
Method
method
=
EventQueue
.
class
.
getDeclaredMethod
(
"wakeup"
,
new
Class
[]
{
Boolean
.
TYPE
}
);
if
(
method
!=
null
)
{
if
(
method
!=
null
)
{
...
@@ -386,8 +387,8 @@ public abstract class SunToolkit extends Toolkit
...
@@ -386,8 +387,8 @@ public abstract class SunToolkit extends Toolkit
// Maps from non-Component/MenuComponent to AppContext.
// Maps from non-Component/MenuComponent to AppContext.
// WeakHashMap<Component,AppContext>
// WeakHashMap<Component,AppContext>
private
static
final
Map
appContextMap
=
private
static
final
Map
<
Object
,
AppContext
>
appContextMap
=
Collections
.
synchronizedMap
(
new
WeakHashMap
());
Collections
.
synchronizedMap
(
new
WeakHashMap
<
Object
,
AppContext
>
());
/**
/**
* Sets the appContext field of target. If target is not a Component or
* Sets the appContext field of target. If target is not a Component or
...
@@ -437,7 +438,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -437,7 +438,7 @@ public abstract class SunToolkit extends Toolkit
if
(
context
==
null
)
{
if
(
context
==
null
)
{
// target is not a Component/MenuComponent, try the
// target is not a Component/MenuComponent, try the
// appContextMap.
// appContextMap.
context
=
(
AppContext
)
appContextMap
.
get
(
target
);
context
=
appContextMap
.
get
(
target
);
}
}
return
context
;
return
context
;
}
}
...
@@ -519,9 +520,9 @@ public abstract class SunToolkit extends Toolkit
...
@@ -519,9 +520,9 @@ public abstract class SunToolkit extends Toolkit
private
static
FocusTraversalPolicy
createLayoutPolicy
()
{
private
static
FocusTraversalPolicy
createLayoutPolicy
()
{
FocusTraversalPolicy
policy
=
null
;
FocusTraversalPolicy
policy
=
null
;
try
{
try
{
Class
layoutPolicyClass
=
Class
<?>
layoutPolicyClass
=
Class
.
forName
(
"javax.swing.LayoutFocusTraversalPolicy"
);
Class
.
forName
(
"javax.swing.LayoutFocusTraversalPolicy"
);
policy
=
(
FocusTraversalPolicy
)
layoutPolicyClass
.
newInstance
();
policy
=
(
FocusTraversalPolicy
)
layoutPolicyClass
.
newInstance
();
}
}
catch
(
ClassNotFoundException
e
)
{
catch
(
ClassNotFoundException
e
)
{
assert
false
;
assert
false
;
...
@@ -642,11 +643,13 @@ public abstract class SunToolkit extends Toolkit
...
@@ -642,11 +643,13 @@ public abstract class SunToolkit extends Toolkit
* Fixed 5064013: the InvocationEvent time should be equals
* Fixed 5064013: the InvocationEvent time should be equals
* the time of the ActionEvent
* the time of the ActionEvent
*/
*/
@SuppressWarnings
(
"serial"
)
public
static
void
executeOnEventHandlerThread
(
Object
target
,
public
static
void
executeOnEventHandlerThread
(
Object
target
,
Runnable
runnable
,
Runnable
runnable
,
final
long
when
)
{
final
long
when
)
{
executeOnEventHandlerThread
(
new
PeerEvent
(
target
,
runnable
,
PeerEvent
.
PRIORITY_EVENT
){
executeOnEventHandlerThread
(
public
long
getWhen
(){
new
PeerEvent
(
target
,
runnable
,
PeerEvent
.
PRIORITY_EVENT
)
{
public
long
getWhen
()
{
return
when
;
return
when
;
}
}
});
});
...
@@ -727,10 +730,12 @@ public abstract class SunToolkit extends Toolkit
...
@@ -727,10 +730,12 @@ public abstract class SunToolkit extends Toolkit
protected
abstract
int
getScreenWidth
();
protected
abstract
int
getScreenWidth
();
protected
abstract
int
getScreenHeight
();
protected
abstract
int
getScreenHeight
();
@SuppressWarnings
(
"deprecation"
)
public
FontMetrics
getFontMetrics
(
Font
font
)
{
public
FontMetrics
getFontMetrics
(
Font
font
)
{
return
FontDesignMetrics
.
getMetrics
(
font
);
return
FontDesignMetrics
.
getMetrics
(
font
);
}
}
@SuppressWarnings
(
"deprecation"
)
public
String
[]
getFontList
()
{
public
String
[]
getFontList
()
{
String
[]
hardwiredFontList
=
{
String
[]
hardwiredFontList
=
{
Font
.
DIALOG
,
Font
.
SANS_SERIF
,
Font
.
SERIF
,
Font
.
MONOSPACED
,
Font
.
DIALOG
,
Font
.
SANS_SERIF
,
Font
.
SERIF
,
Font
.
MONOSPACED
,
...
@@ -1156,10 +1161,10 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1156,10 +1161,10 @@ public abstract class SunToolkit extends Toolkit
public
static
Locale
getStartupLocale
()
{
public
static
Locale
getStartupLocale
()
{
if
(
startupLocale
==
null
)
{
if
(
startupLocale
==
null
)
{
String
language
,
region
,
country
,
variant
;
String
language
,
region
,
country
,
variant
;
language
=
(
String
)
AccessController
.
doPrivileged
(
language
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"user.language"
,
"en"
));
new
GetPropertyAction
(
"user.language"
,
"en"
));
// for compatibility, check for old user.region property
// for compatibility, check for old user.region property
region
=
(
String
)
AccessController
.
doPrivileged
(
region
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"user.region"
));
new
GetPropertyAction
(
"user.region"
));
if
(
region
!=
null
)
{
if
(
region
!=
null
)
{
// region can be of form country, country_variant, or _variant
// region can be of form country, country_variant, or _variant
...
@@ -1172,9 +1177,9 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1172,9 +1177,9 @@ public abstract class SunToolkit extends Toolkit
variant
=
""
;
variant
=
""
;
}
}
}
else
{
}
else
{
country
=
(
String
)
AccessController
.
doPrivileged
(
country
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"user.country"
,
""
));
new
GetPropertyAction
(
"user.country"
,
""
));
variant
=
(
String
)
AccessController
.
doPrivileged
(
variant
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"user.variant"
,
""
));
new
GetPropertyAction
(
"user.variant"
,
""
));
}
}
startupLocale
=
new
Locale
(
language
,
country
,
variant
);
startupLocale
=
new
Locale
(
language
,
country
,
variant
);
...
@@ -1254,7 +1259,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1254,7 +1259,7 @@ public abstract class SunToolkit extends Toolkit
* @return <code>true</code>, if XEmbed is needed, <code>false</code> otherwise
* @return <code>true</code>, if XEmbed is needed, <code>false</code> otherwise
*/
*/
public
static
boolean
needsXEmbed
()
{
public
static
boolean
needsXEmbed
()
{
String
noxembed
=
(
String
)
AccessController
.
String
noxembed
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"sun.awt.noxembed"
,
"false"
));
doPrivileged
(
new
GetPropertyAction
(
"sun.awt.noxembed"
,
"false"
));
if
(
"true"
.
equals
(
noxembed
))
{
if
(
"true"
.
equals
(
noxembed
))
{
return
false
;
return
false
;
...
@@ -1466,7 +1471,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1466,7 +1471,7 @@ public abstract class SunToolkit extends Toolkit
||
comp
instanceof
Window
);
||
comp
instanceof
Window
);
}
}
public
static
Method
getMethod
(
final
Class
clz
,
final
String
methodName
,
final
Class
[]
params
)
{
public
static
Method
getMethod
(
final
Class
<?>
clz
,
final
String
methodName
,
final
Class
[]
params
)
{
Method
res
=
null
;
Method
res
=
null
;
try
{
try
{
res
=
AccessController
.
doPrivileged
(
new
PrivilegedExceptionAction
<
Method
>()
{
res
=
AccessController
.
doPrivileged
(
new
PrivilegedExceptionAction
<
Method
>()
{
...
@@ -1482,6 +1487,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1482,6 +1487,7 @@ public abstract class SunToolkit extends Toolkit
return
res
;
return
res
;
}
}
@SuppressWarnings
(
"serial"
)
public
static
class
OperationTimedOut
extends
RuntimeException
{
public
static
class
OperationTimedOut
extends
RuntimeException
{
public
OperationTimedOut
(
String
msg
)
{
public
OperationTimedOut
(
String
msg
)
{
super
(
msg
);
super
(
msg
);
...
@@ -1489,9 +1495,12 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1489,9 +1495,12 @@ public abstract class SunToolkit extends Toolkit
public
OperationTimedOut
()
{
public
OperationTimedOut
()
{
}
}
}
}
@SuppressWarnings
(
"serial"
)
public
static
class
InfiniteLoop
extends
RuntimeException
{
public
static
class
InfiniteLoop
extends
RuntimeException
{
}
}
@SuppressWarnings
(
"serial"
)
public
static
class
IllegalThreadException
extends
RuntimeException
{
public
static
class
IllegalThreadException
extends
RuntimeException
{
public
IllegalThreadException
(
String
msg
)
{
public
IllegalThreadException
(
String
msg
)
{
super
(
msg
);
super
(
msg
);
...
@@ -1648,6 +1657,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1648,6 +1657,7 @@ public abstract class SunToolkit extends Toolkit
* Should return <code>true</code> if more processing is
* Should return <code>true</code> if more processing is
* necessary, <code>false</code> otherwise.
* necessary, <code>false</code> otherwise.
*/
*/
@SuppressWarnings
(
"serial"
)
protected
final
boolean
waitForIdle
(
final
long
timeout
)
{
protected
final
boolean
waitForIdle
(
final
long
timeout
)
{
flushPendingEvents
();
flushPendingEvents
();
boolean
queueWasEmpty
=
isEQEmpty
();
boolean
queueWasEmpty
=
isEQEmpty
();
...
@@ -1831,7 +1841,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1831,7 +1841,7 @@ public abstract class SunToolkit extends Toolkit
Toolkit
tk
=
Toolkit
.
getDefaultToolkit
();
Toolkit
tk
=
Toolkit
.
getDefaultToolkit
();
if
(
tk
instanceof
SunToolkit
)
{
if
(
tk
instanceof
SunToolkit
)
{
systemAAFonts
=
systemAAFonts
=
(
String
)
AccessController
.
doPrivileged
(
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"awt.useSystemAAFontSettings"
));
new
GetPropertyAction
(
"awt.useSystemAAFontSettings"
));
}
}
if
(
systemAAFonts
!=
null
)
{
if
(
systemAAFonts
!=
null
)
{
...
@@ -1898,7 +1908,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1898,7 +1908,7 @@ public abstract class SunToolkit extends Toolkit
if
(
consumeNextKeyTypedMethod
==
null
)
{
if
(
consumeNextKeyTypedMethod
==
null
)
{
consumeNextKeyTypedMethod
=
getMethod
(
DefaultKeyboardFocusManager
.
class
,
consumeNextKeyTypedMethod
=
getMethod
(
DefaultKeyboardFocusManager
.
class
,
"consumeNextKeyTyped"
,
"consumeNextKeyTyped"
,
new
Class
[]
{
KeyEvent
.
class
});
new
Class
<?>
[]
{
KeyEvent
.
class
});
}
}
try
{
try
{
consumeNextKeyTypedMethod
.
invoke
(
KeyboardFocusManager
.
getCurrentKeyboardFocusManager
(),
consumeNextKeyTypedMethod
.
invoke
(
KeyboardFocusManager
.
getCurrentKeyboardFocusManager
(),
...
@@ -1930,8 +1940,8 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1930,8 +1940,8 @@ public abstract class SunToolkit extends Toolkit
* Returns the value of the system property indicated by the specified key.
* Returns the value of the system property indicated by the specified key.
*/
*/
public
static
String
getSystemProperty
(
final
String
key
)
{
public
static
String
getSystemProperty
(
final
String
key
)
{
return
(
String
)
AccessController
.
doPrivileged
(
new
PrivilegedAction
()
{
return
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
String
>
()
{
public
Object
run
()
{
public
String
run
()
{
return
System
.
getProperty
(
key
);
return
System
.
getProperty
(
key
);
}
}
});
});
...
@@ -1941,8 +1951,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -1941,8 +1951,7 @@ public abstract class SunToolkit extends Toolkit
* Returns the boolean value of the system property indicated by the specified key.
* Returns the boolean value of the system property indicated by the specified key.
*/
*/
protected
static
Boolean
getBooleanSystemProperty
(
String
key
)
{
protected
static
Boolean
getBooleanSystemProperty
(
String
key
)
{
return
Boolean
.
valueOf
(
AccessController
.
return
AccessController
.
doPrivileged
(
new
GetBooleanAction
(
key
));
doPrivileged
(
new
GetBooleanAction
(
key
)));
}
}
private
static
Boolean
sunAwtDisableMixing
=
null
;
private
static
Boolean
sunAwtDisableMixing
=
null
;
...
@@ -2015,7 +2024,7 @@ public abstract class SunToolkit extends Toolkit
...
@@ -2015,7 +2024,7 @@ public abstract class SunToolkit extends Toolkit
*/
*/
public
static
boolean
isContainingTopLevelTranslucent
(
Component
c
)
{
public
static
boolean
isContainingTopLevelTranslucent
(
Component
c
)
{
Window
w
=
getContainingWindow
(
c
);
Window
w
=
getContainingWindow
(
c
);
return
w
!=
null
&&
((
Window
)
w
)
.
getOpacity
()
<
1.0f
;
return
w
!=
null
&&
w
.
getOpacity
()
<
1.0f
;
}
}
/**
/**
...
@@ -2057,14 +2066,14 @@ public abstract class SunToolkit extends Toolkit
...
@@ -2057,14 +2066,14 @@ public abstract class SunToolkit extends Toolkit
return
isInstanceOf
(
obj
.
getClass
(),
type
);
return
isInstanceOf
(
obj
.
getClass
(),
type
);
}
}
private
static
boolean
isInstanceOf
(
Class
cls
,
String
type
)
{
private
static
boolean
isInstanceOf
(
Class
<?>
cls
,
String
type
)
{
if
(
cls
==
null
)
return
false
;
if
(
cls
==
null
)
return
false
;
if
(
cls
.
getName
().
equals
(
type
))
{
if
(
cls
.
getName
().
equals
(
type
))
{
return
true
;
return
true
;
}
}
for
(
Class
c
:
cls
.
getInterfaces
())
{
for
(
Class
<?>
c
:
cls
.
getInterfaces
())
{
if
(
c
.
getName
().
equals
(
type
))
{
if
(
c
.
getName
().
equals
(
type
))
{
return
true
;
return
true
;
}
}
...
...
src/share/classes/sun/awt/UngrabEvent.java
浏览文件 @
55e39e30
...
@@ -39,7 +39,9 @@ import java.awt.Component;
...
@@ -39,7 +39,9 @@ import java.awt.Component;
* <p>Notice that this event is not generated on mouse click inside of the window area.
* <p>Notice that this event is not generated on mouse click inside of the window area.
* <p>To listen for this event, install AWTEventListener with {@value sun.awt.SunToolkit#GRAB_EVENT_MASK}
* <p>To listen for this event, install AWTEventListener with {@value sun.awt.SunToolkit#GRAB_EVENT_MASK}
*/
*/
@SuppressWarnings
(
"serial"
)
public
class
UngrabEvent
extends
AWTEvent
{
public
class
UngrabEvent
extends
AWTEvent
{
private
final
static
int
UNGRAB_EVENT_ID
=
1998
;
private
final
static
int
UNGRAB_EVENT_ID
=
1998
;
public
UngrabEvent
(
Component
source
)
{
public
UngrabEvent
(
Component
source
)
{
...
...
src/share/classes/sun/awt/VariableGridLayout.java
已删除
100644 → 0
浏览文件 @
0c476fef
/*
* Copyright (c) 1995, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
sun.awt
;
import
java.awt.*
;
import
java.util.BitSet
;
/**
* A layout manager for a container that lays out grids. Allows setting
* the relative sizes of rows and columns.
*
* @author Herb Jellinek
*/
public
class
VariableGridLayout
extends
GridLayout
{
BitSet
rowsSet
=
new
BitSet
();
double
rowFractions
[]
=
null
;
BitSet
colsSet
=
new
BitSet
();
double
colFractions
[]
=
null
;
int
rows
;
int
cols
;
int
hgap
;
int
vgap
;
/**
* Creates a grid layout with the specified rows and specified columns.
* @param rows the rows
* @param cols the columns
*/
public
VariableGridLayout
(
int
rows
,
int
cols
)
{
this
(
rows
,
cols
,
0
,
0
);
if
(
rows
!=
0
)
{
rowsSet
=
new
BitSet
(
rows
);
stdRowFractions
(
rows
);
}
if
(
cols
!=
0
)
{
colsSet
=
new
BitSet
(
cols
);
stdColFractions
(
cols
);
}
}
/**
* Creates a grid layout with the specified rows, columns,
* horizontal gap, and vertical gap.
* @param rows the rows
* @param cols the columns
* @param hgap the horizontal gap variable
* @param vgap the vertical gap variable
* @exception IllegalArgumentException If the rows and columns are invalid.
*/
public
VariableGridLayout
(
int
rows
,
int
cols
,
int
hgap
,
int
vgap
)
{
super
(
rows
,
cols
,
hgap
,
vgap
);
this
.
rows
=
rows
;
this
.
cols
=
cols
;
this
.
hgap
=
hgap
;
this
.
vgap
=
vgap
;
if
(
rows
!=
0
)
{
rowsSet
=
new
BitSet
(
rows
);
stdRowFractions
(
rows
);
}
if
(
cols
!=
0
)
{
colsSet
=
new
BitSet
(
cols
);
stdColFractions
(
cols
);
}
}
void
stdRowFractions
(
int
nrows
)
{
rowFractions
=
new
double
[
nrows
];
for
(
int
i
=
0
;
i
<
nrows
;
i
++)
{
rowFractions
[
i
]
=
1.0
/
nrows
;
}
}
void
stdColFractions
(
int
ncols
)
{
colFractions
=
new
double
[
ncols
];
for
(
int
i
=
0
;
i
<
ncols
;
i
++)
{
colFractions
[
i
]
=
1.0
/
ncols
;
}
}
public
void
setRowFraction
(
int
rowNum
,
double
fraction
)
{
rowsSet
.
set
(
rowNum
);
rowFractions
[
rowNum
]
=
fraction
;
}
public
void
setColFraction
(
int
colNum
,
double
fraction
)
{
colsSet
.
set
(
colNum
);
colFractions
[
colNum
]
=
fraction
;
}
public
double
getRowFraction
(
int
rowNum
)
{
return
rowFractions
[
rowNum
];
}
public
double
getColFraction
(
int
colNum
)
{
return
colFractions
[
colNum
];
}
void
allocateExtraSpace
(
double
vec
[],
BitSet
userSet
)
{
// collect the space that's been explicitly allocated...
double
total
=
0.0
;
int
unallocated
=
0
;
int
i
;
for
(
i
=
0
;
i
<
vec
.
length
;
i
++)
{
if
(
userSet
.
get
(
i
))
{
total
+=
vec
[
i
];
}
else
{
unallocated
++;
}
}
// ... then spread the extra space
if
(
unallocated
!=
0
)
{
double
space
=
(
1.0
-
total
)
/
unallocated
;
for
(
i
=
0
;
i
<
vec
.
length
;
i
++)
{
if
(!
userSet
.
get
(
i
))
{
vec
[
i
]
=
space
;
userSet
.
set
(
i
);
}
}
}
}
void
allocateExtraSpace
()
{
allocateExtraSpace
(
rowFractions
,
rowsSet
);
allocateExtraSpace
(
colFractions
,
colsSet
);
}
/**
* Lays out the container in the specified panel.
* @param parent the specified component being laid out
* @see Container
*/
public
void
layoutContainer
(
Container
parent
)
{
Insets
insets
=
parent
.
insets
();
int
ncomponents
=
parent
.
countComponents
();
int
nrows
=
rows
;
int
ncols
=
cols
;
if
(
nrows
>
0
)
{
ncols
=
(
ncomponents
+
nrows
-
1
)
/
nrows
;
}
else
{
nrows
=
(
ncomponents
+
ncols
-
1
)
/
ncols
;
}
if
(
rows
==
0
)
{
stdRowFractions
(
nrows
);
}
if
(
cols
==
0
)
{
stdColFractions
(
ncols
);
}
Dimension
size
=
parent
.
size
();
int
w
=
size
.
width
-
(
insets
.
left
+
insets
.
right
);
int
h
=
size
.
height
-
(
insets
.
top
+
insets
.
bottom
);
w
=
(
w
-
(
ncols
-
1
)
*
hgap
);
h
=
(
h
-
(
nrows
-
1
)
*
vgap
);
allocateExtraSpace
();
for
(
int
c
=
0
,
x
=
insets
.
left
;
c
<
ncols
;
c
++)
{
int
colWidth
=
(
int
)(
getColFraction
(
c
)
*
w
);
for
(
int
r
=
0
,
y
=
insets
.
top
;
r
<
nrows
;
r
++)
{
int
i
=
r
*
ncols
+
c
;
int
rowHeight
=
(
int
)(
getRowFraction
(
r
)
*
h
);
if
(
i
<
ncomponents
)
{
parent
.
getComponent
(
i
).
reshape
(
x
,
y
,
colWidth
,
rowHeight
);
}
y
+=
rowHeight
+
vgap
;
}
x
+=
colWidth
+
hgap
;
}
}
static
String
fracsToString
(
double
array
[])
{
String
result
=
"["
+
array
.
length
+
"]"
;
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
result
+=
"<"
+
array
[
i
]+
">"
;
}
return
result
;
}
/**
* Returns the String representation of this VariableGridLayout's values.
*/
public
String
toString
()
{
return
getClass
().
getName
()
+
"[hgap="
+
hgap
+
",vgap="
+
vgap
+
",rows="
+
rows
+
",cols="
+
cols
+
",rowFracs="
+
fracsToString
(
rowFractions
)
+
",colFracs="
+
fracsToString
(
colFractions
)
+
"]"
;
}
}
src/share/classes/sun/awt/VerticalBagLayout.java
已删除
100644 → 0
浏览文件 @
0c476fef
/*
* Copyright (c) 1995, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
sun.awt
;
import
java.awt.*
;
/**
* A vertical 'bag' of Components. Allocates space for each Component from
* top to bottom.
*
* @author Herb Jellinek
*/
public
class
VerticalBagLayout
implements
LayoutManager
{
int
vgap
;
/**
* Constructs a new VerticalBagLayout.
*/
public
VerticalBagLayout
()
{
this
(
0
);
}
/**
* Constructs a VerticalBagLayout with the specified gaps.
* @param vgap the vertical gap
*/
public
VerticalBagLayout
(
int
vgap
)
{
this
.
vgap
=
vgap
;
}
/**
* Adds the specified named component to the layout.
* @param name the String name
* @param comp the component to be added
*/
public
void
addLayoutComponent
(
String
name
,
Component
comp
)
{
}
/**
* Removes the specified component from the layout.
* @param comp the component to be removed
*/
public
void
removeLayoutComponent
(
Component
comp
)
{
}
/**
* Returns the minimum dimensions needed to lay out the components
* contained in the specified target container.
* @param target the Container on which to do the layout
* @see Container
* @see #preferredLayoutSize
*/
public
Dimension
minimumLayoutSize
(
Container
target
)
{
Dimension
dim
=
new
Dimension
();
int
nmembers
=
target
.
countComponents
();
for
(
int
i
=
0
;
i
<
nmembers
;
i
++)
{
Component
comp
=
target
.
getComponent
(
i
);
if
(
comp
.
isVisible
())
{
Dimension
d
=
comp
.
minimumSize
();
dim
.
width
=
Math
.
max
(
d
.
width
,
dim
.
width
);
dim
.
height
+=
d
.
height
+
vgap
;
}
}
Insets
insets
=
target
.
insets
();
dim
.
width
+=
insets
.
left
+
insets
.
right
;
dim
.
height
+=
insets
.
top
+
insets
.
bottom
;
return
dim
;
}
/**
* Returns the preferred dimensions for this layout given the components
* in the specified target container.
* @param target the component which needs to be laid out
* @see Container
* @see #minimumLayoutSize
*/
public
Dimension
preferredLayoutSize
(
Container
target
)
{
Dimension
dim
=
new
Dimension
();
int
nmembers
=
target
.
countComponents
();
for
(
int
i
=
0
;
i
<
nmembers
;
i
++)
{
Component
comp
=
target
.
getComponent
(
i
);
if
(
true
||
comp
.
isVisible
())
{
Dimension
d
=
comp
.
preferredSize
();
dim
.
width
=
Math
.
max
(
d
.
width
,
dim
.
width
);
dim
.
height
+=
d
.
height
+
vgap
;
}
}
Insets
insets
=
target
.
insets
();
dim
.
width
+=
insets
.
left
+
insets
.
right
;
dim
.
height
+=
insets
.
top
+
insets
.
bottom
;
return
dim
;
}
/**
* Lays out the specified container. This method will actually reshape the
* components in the specified target container in order to satisfy the
* constraints of the VerticalBagLayout object.
* @param target the component being laid out
* @see Container
*/
public
void
layoutContainer
(
Container
target
)
{
Insets
insets
=
target
.
insets
();
int
top
=
insets
.
top
;
int
bottom
=
target
.
size
().
height
-
insets
.
bottom
;
int
left
=
insets
.
left
;
int
right
=
target
.
size
().
width
-
insets
.
right
;
int
nmembers
=
target
.
countComponents
();
for
(
int
i
=
0
;
i
<
nmembers
;
i
++)
{
Component
comp
=
target
.
getComponent
(
i
);
if
(
comp
.
isVisible
())
{
int
compHeight
=
comp
.
size
().
height
;
comp
.
resize
(
right
-
left
,
compHeight
);
Dimension
d
=
comp
.
preferredSize
();
comp
.
reshape
(
left
,
top
,
right
-
left
,
d
.
height
);
top
+=
d
.
height
+
vgap
;
}
}
}
/**
* Returns the String representation of this VerticalBagLayout's values.
*/
public
String
toString
()
{
return
getClass
().
getName
()
+
"[vgap="
+
vgap
+
"]"
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录