com.sun.awt.AWTUtilities.setWindowOpacity相关说明
在eclipse中(jdk1.6.*)版本中出现编译不通过而报错,报错是因为这个包里面的方法不属于jdk正式版本,也就是不能保证下个版本还存在,所以编译器会拒绝,你可以在eclipse中如下设置: 选择Window->Preferences->Java->Compiler->Errors/Warnings;然后选择Deprecated and restricted API,将 Deprecated API从ERROR改为Warning即可!
package Com.SwingTest; import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JWindow; import com.sun.awt.AWTUtilities; public class SwingText_08 { private int _height = ; // 气泡提示高
private int _step = ; // 设定循环的步长
private int _stepTime = ; // 每步时间
private int _displayTime = ; // 显示时间
private Font _font; // 字体 /**
* 构造函数,初始化默认气泡提示设置
*
*/
public SwingText_08()
{
_font = new Font("微软雅黑", , );// 设定字体
try {
JWindow.class.getMethod("setAlwaysOnTop",
new Class[] { Boolean.class });
} catch (Exception e) {
}
} /**
* 重构JWindow用于显示单一气泡提示框
*
*/
class ToolTipSingle extends Window
{
private static final long serialVersionUID = 1L;
private JButton _message = new JButton(){
/**
*
*/
private static final long serialVersionUID = 1L; @Override
public void repaint()
{
}
}; @SuppressWarnings("deprecation")
public ToolTipSingle(String msg) {
super(null); int cntText=msg.length();
int with = cntText*+;
int height = _height; Rectangle screenRect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
int screenHeight = (int) screenRect.height;
int screenWidth = (int) screenRect.width; int posx = screenWidth/-with/;
int posy = screenHeight/-height/; setBounds(posx, posy, with, height);
_message.setFont(getMessageFont());
_message.setText(msg); _message.setFocusPainted(false);
//_message.setEnabled(false);
add(_message, BorderLayout.CENTER); setAlwaysOnTop(true);
setLocationRelativeTo(null); show(true);
} /**
* 动画开始
*
*/
public void animate() {
new Animation(this).start();
}
} /**
* 此类处则动画处理
*
*/
class Animation extends Thread
{ ToolTipSingle _single; public Animation(ToolTipSingle single) {
this._single = single;
} /**
* 开始动画处理
*/
@SuppressWarnings("deprecation")
public void run() {
try {
float value = 0.0f;
while((value+0.02)<1.0f)
{
value+=0.02f;
com.sun.awt.AWTUtilities.setWindowOpacity(_single, value);
Thread.sleep();
} while(_displayTime>)
{
Thread.sleep();
_displayTime = _displayTime-;
} value=;
while((value-0.02)>0f)
{
value-=0.02f;
com.sun.awt.AWTUtilities.setWindowOpacity(_single, value);
Thread.sleep();
} } catch (Exception e) {
throw new RuntimeException(e);
} _single.show(false);
}
} /**
* 设定显示信息
*
* @param icon
* @param msg
*/
public void show(String msg) {
new ToolTipSingle(msg).animate();
} /**
* 获得当前消息字体
*
* @return
*/
public Font getMessageFont() {
return _font;
} /**
* 设置当前消息字体
*
* @param font
*/
public void setMessageFont(Font font) {
_font = font;
} /**
* 获得显示时间
*
* @return
*/
public int getDisplayTime() {
return _displayTime;
} /**
* 设置显示时间
*
* @param displayTime
*/
public void setDisplayTime(int displayTime) {
this._displayTime = displayTime;
} /**
* 获得循环步长
*
* @return
*/
public int getStep() {
return _step;
} /**
* 设定循环步长
*
* @param _step
*/
public void setStep(int _step) {
this._step = _step;
} public int getStepTime() {
return _stepTime;
} public void setStepTime(int _stepTime) {
this._stepTime = _stepTime;
} public static void main(String[] argv)
{
new SwingText_08().show("全部任务已经载入完成!");
}
}
com.sun.awt.AWTUtilities.setWindowOpacity相关说明的更多相关文章
- Java:import com.sun.awt.AWTUtilities;报错
参考网址:http://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-req ...
- linux下验证码无法显示:Could not initialize class sun.awt.X1 解决方案
转自:http://my.oschina.net/xiangtao/blog/28441 网站验证码突然无法显示,并报如下错误. Caused by: java.lang.NoClassDefFoun ...
- weblogic .NoClassDefFoundError: Could not initialize class sun.awt.X11Graphi
这个是常见问题,可以通过增加Weblogic的启动参数来解决: -Djava.awt.headless=true 你可以修改 startWebLogic.sh 文件. export JAVA_OPTI ...
- weblogic环境,应用上传图片报Could not initialize class sun.awt.X11.XToolkit
问题描写叙述 遇到的问题是在weblogic环境,应用在上传图片的时候报Could not initialize class sun.awt.X11.XToolkit 错误. 详细错误例如以下 17: ...
- exception java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
exception java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironmen ...
- Linux下java验证码不显示:Could not initialize class sun.awt.X11FontManager
一.问题 javaweb项目,登录的时候有个图片验证码的功能.在Windows本地测试能够正常显示,部署到Linux上就不行了.报错如下: org.springframework.web.util.N ...
- java:提示Could not initialize class sun.awt.X11GraphicsEnvironment
前几天发现tomcat提示 Could not initialize class sun.awt.X11GraphicsEnvironment 问题.以为不验证,就没太关注,今天发现,有同事提示了个 ...
- 验证码无法显示,服务器端出现异常:Could not initialize class sun.awt.X11GraphicsEnvironment
异常信息: Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvir ...
- Linux下验证码无法显示,Could not initialize class sun.awt.X1 解决方案
环境:Oracle Linux 6.4,JDK1.6,Weblogic11g 在通过java.awt生成图片验证码时,提示: Could not initialize class sun.awt.X1 ...
随机推荐
- shell学习四十八天----文件校验和匹配
文件校验和匹配 要是你怀疑可能有非常多文件具有同样的内文,而是用cmp或diff进行比較全部横队的比較,导致所花费的时间会随着文件数目增长成次方的增长. 这是能够使用file checksum(文件校 ...
- caffe make 编译
其实嘛,出现这个的原因在于,已经编译过啦,没有任何改动,那还烦劳编译啥呢. 那Linux又是如何知道已经编译过了呢? 那就要看makefile的规则啦.makefile的规则是所想产生的文件需要依赖很 ...
- django1.8输出一些非HTML内容
在reportlab库中可以生成pdf文件 在https://www.reportlab.com/pypi/packages/ 下载需要的版本然后,在命令行里通过pip安装.pip instal ...
- 怎么使用 ab.exe 测试多个url。 how to use ab.exe test many url
from a commandline in windows: for /F %q in (list.txt) DO ab -n 1000 https://test.com/search?%q I ...
- centos 下Qt安装 mysql驱动(亲测可行)
(前半部分没有试过,因为我的有mysql驱动,实在抱歉) 1.预防万一,先安装一下mysql-devel(一定要装!). 不安装的话后面编译会出现找不到-lmysqlclient的问题. 2. 开始编 ...
- 8个非常实用的PHP安全函数,你知道几个?
原文:Useful functions to provide secure PHP application 译文:实用的PHP安全函数 译者:dwqs 安全是编程很重要的一个方面.在不论什么一种编程语 ...
- Spring Cloud Eureka自我保护机制(服务无法剔除)
说明 自我保护背景 首先对Eureka注册中心需要了解的是Eureka各个节点都是平等的,没有ZK中角色的概念, 即使N-1个节点挂掉也不会影响其他节点的正常运行. 默认情况下,如果Eureka Se ...
- 判断IP是否为爬虫IP
方法一: 通过国外网站验证:http://bot.myip.ms/123.125.71.12 返回结果: IP/Domain - 123.125.71.12: Baidu Bot on this ...
- LeetCode: Wildcard Matching 解题报告
Wildcard MatchingImplement wildcard pattern matching with support for '?' and '*'. '?' Matches any s ...
- Linux Shell sort排序常用命令(转载)
转载自:http://blog.csdn.net/monkeyduck/article/details/10097829 1 sort的工作原理 sort将文件的每一行作为一个单位,相互比较,比较原则 ...