Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a7dd4655
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看板
提交
a7dd4655
编写于
3月 30, 2011
作者:
M
mrkam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7027687: /applets/NervousText demo needs to be improved
Reviewed-by: alexp
上级
fb07f23a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
18 deletion
+31
-18
src/share/demo/applets/NervousText/NervousText.java
src/share/demo/applets/NervousText/NervousText.java
+31
-18
未找到文件。
src/share/demo/applets/NervousText/NervousText.java
浏览文件 @
a7dd4655
/*
* Copyright (c) 1997, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 20
11
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -29,37 +29,37 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import
java.awt.event.*
;
import
java.awt.Graphics
;
import
java.awt.Font
;
import
java.applet.Applet
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseListener
;
/**
* An applet that displays jittering text on the screen.
*
* @author Daniel Wyszynski 04/12/95
* @
modified
05/09/95 kwalrath Changed string; added thread suspension
* @
modified
02/06/98 madbot removed use of suspend and resume and cleaned up
* @
author
05/09/95 kwalrath Changed string; added thread suspension
* @
author
02/06/98 madbot removed use of suspend and resume and cleaned up
*/
@SuppressWarnings
(
"serial"
)
public
class
NervousText
extends
Applet
implements
Runnable
,
MouseListener
{
String
banner
;
// The text to be displayed
char
bannerChars
[];
// The same text as an array of characters
char
attributes
[];
// Character attributes ('^' for superscript)
Thread
runner
=
null
;
// The thread that is displaying the text
boolean
threadSuspended
;
// True when thread suspended (via mouse click)
static
final
int
REGULAR_WD
=
15
;
static
final
int
REGULAR_HT
=
36
;
static
final
int
SMALL_WD
=
12
;
static
final
int
SMALL_HT
=
24
;
Font
regularFont
=
new
Font
(
"Serif"
,
Font
.
BOLD
,
REGULAR_HT
);
Font
smallFont
=
new
Font
(
"Serif"
,
Font
.
BOLD
,
SMALL_HT
);
@Override
public
void
init
()
{
banner
=
getParameter
(
"text"
);
if
(
banner
==
null
)
{
...
...
@@ -67,8 +67,8 @@ public class NervousText extends Applet implements Runnable, MouseListener {
}
int
bannerLength
=
banner
.
length
();
StringBu
ffer
bc
=
new
StringBuff
er
(
bannerLength
);
StringBu
ffer
attrs
=
new
StringBuff
er
(
bannerLength
);
StringBu
ilder
bc
=
new
StringBuild
er
(
bannerLength
);
StringBu
ilder
attrs
=
new
StringBuild
er
(
bannerLength
);
int
wd
=
0
;
for
(
int
i
=
0
;
i
<
bannerLength
;
i
++)
{
char
c
=
banner
.
charAt
(
i
);
...
...
@@ -89,7 +89,7 @@ public class NervousText extends Applet implements Runnable, MouseListener {
}
bannerLength
=
bc
.
length
();
bannerChars
=
new
char
[
bannerLength
];
bannerChars
=
new
char
[
bannerLength
];
attributes
=
new
char
[
bannerLength
];
bc
.
getChars
(
0
,
bannerLength
,
bannerChars
,
0
);
attrs
.
getChars
(
0
,
bannerLength
,
attributes
,
0
);
...
...
@@ -99,15 +99,18 @@ public class NervousText extends Applet implements Runnable, MouseListener {
addMouseListener
(
this
);
}
@Override
public
void
destroy
()
{
removeMouseListener
(
this
);
}
@Override
public
void
start
()
{
runner
=
new
Thread
(
this
);
runner
.
start
();
}
@Override
public
synchronized
void
stop
()
{
runner
=
null
;
if
(
threadSuspended
)
{
...
...
@@ -116,22 +119,24 @@ public class NervousText extends Applet implements Runnable, MouseListener {
}
}
@Override
public
void
run
()
{
Thread
me
=
Thread
.
currentThread
();
while
(
runner
==
me
)
{
try
{
Thread
.
sleep
(
100
);
synchronized
(
this
)
{
synchronized
(
this
)
{
while
(
threadSuspended
)
{
wait
();
}
}
}
catch
(
InterruptedException
e
){
}
catch
(
InterruptedException
e
)
{
}
repaint
();
}
}
@Override
public
void
paint
(
Graphics
g
)
{
int
length
=
bannerChars
.
length
;
for
(
int
i
=
0
,
x
=
0
;
i
<
length
;
i
++)
{
...
...
@@ -152,33 +157,41 @@ public class NervousText extends Applet implements Runnable, MouseListener {
}
}
@Override
public
synchronized
void
mousePressed
(
MouseEvent
e
)
{
e
.
consume
();
threadSuspended
=
!
threadSuspended
;
if
(!
threadSuspended
)
if
(!
threadSuspended
)
{
notify
();
}
}
@Override
public
void
mouseReleased
(
MouseEvent
e
)
{
}
@Override
public
void
mouseEntered
(
MouseEvent
e
)
{
}
@Override
public
void
mouseExited
(
MouseEvent
e
)
{
}
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
}
@Override
public
String
getAppletInfo
()
{
return
"Title: NervousText\nAuthor: Daniel Wyszynski\nDisplays a text banner that jitters."
;
return
"Title: NervousText\nAuthor: Daniel Wyszynski\n"
+
"Displays a text banner that jitters."
;
}
@Override
public
String
[][]
getParameterInfo
()
{
String
pinfo
[][]
=
{
{
"text"
,
"string"
,
"Text to display"
},
};
{
"text"
,
"string"
,
"Text to display"
},
};
return
pinfo
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录