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 ...
随机推荐
- SqlMapConfig.xml中的setting属性 Ibatis mybatis
<settingscacheModelsEnabled="true"lazyLoadingEnabled="false"enhancementEnable ...
- PHP Client for Mysql Binlog
PHP解析MySQL Binlog,依赖于mysql-replication-listener库 详见:https://github.com/bullsoft/php-binlog Install M ...
- 使用R语言分析股价波动
今天看的R语言.做个笔记. 使用R语言读取雅虎財经数据.分析微软公司(股票代码:MSFT)在2015年股价波动超过百分之十的日期. 然后通过检索新闻的方式,看看微软当天有什么新闻发生,导致股价波动. ...
- chkconfig命令具体介绍
命令介绍: chkconfig命令用来更新.查询.改动不同执行级上的系统服务.比方安装了httpd服务,而且把启动的脚本放在了/etc/rc.d/init.d文件夹下,有时候须要开机自己主动启动它,而 ...
- 【Android】16.5 Android内置的系统服务
分类:C#.Android.VS2015: 创建日期:2016-03-01 一.简介 实际上,在Android.Content.Context类中,Android已经提供了多种类型的系统服务,这些服务 ...
- android framework-下载Android系统源代码
□ apt-get install git-core curl #先下载这两个工具 □ mkdir android-froyo #建立下载目录 □ cd android-froyo #进入下载目录 □ ...
- 57. 3Sum【medium】
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...
- 【转】32位和64位系统区别及int字节数
http://blog.csdn.net/zhongzhiwei/article/details/8678885 一)64位系统和32位有什么区别? 1.64bit CPU拥有更大的寻址能力,最大支持 ...
- 常用的一个cookie 对象,还有path 兼容性问题
//cookievar ck = { getObj:function() { var ck = document.cookie; var obj = {}; if(ck!="" ...
- Oracle PLSQL Demo - 02.SELECT INTO单行赋值[SELECT INTO variables]
declare v_sal number; begin ; dbms_output.put_line(v_sal); end;