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 ...
随机推荐
- cocos2dx 3.1从零学习(四)——内存管理(错误案例分析)
本篇内容文字比較较多,可是这些都是建立在前面三章写代码特别是传值的时候崩溃的基础上的.可能表达的跟正确的机制有出入,还请指正. 假设有不理解的能够联系我.大家能够讨论一下,共同学习. 首先明白一个事实 ...
- CentOS6.4之图解SSH无验证双向登陆配置
配置SSH无登陆验证,在很多场景下是非常方便的,尤其是在管理大型集群服务时,避免了繁琐的密码验证,在安全级别越高的服务器上,通常密码的设置更复杂,配置SSH,不仅可以用密钥保证节点间通信的安全性,同时 ...
- [k8s]通过svc来访问集群podhttp://api:8080/api/v1/namespaces/default/services/mynginx/proxy/
以往的套路是,安装完成k8s集群后-->安装dns-->安装ingress以便外面访问(或者映射nodeport方式) 如果你不想做任何关于ingress/nodeport一些操作.想通过 ...
- 【Android】3.6 地图基本控制方法
分类:C#.Android.VS2015.百度地图应用: 创建日期:2016-02-04 一.简介 文件名:Demo05MapControl.cs 简介:介绍平移和缩放地图,双指操作地图,监听地图点击 ...
- angular学习笔记(十四)-$watch(3)
同样的例子,还可以这样写: <!DOCTYPE html> <html ng-app> <head> <title>11.3$watch监控数据变化&l ...
- sublime php插件
1. Package Control Get Package Control here. 2. Theme - Phoenix and Flatland(扁平) If Sublime Text ...
- 【Maven】maven打包生成可执行jar文件
http://blog.csdn.net/u013177446/article/details/53944424 ******************************************* ...
- LeetCode: Swap Nodes in Pairs 解题报告
Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For exam ...
- eclipse egit 报错 The current branch is not configured for pull No value for key branch.master
eclipse egit 插件 pull报错 The current branch is not configured for pull No value for key branch.master ...
- centos6.4或者6.5使用yum的elrepo源升级内核
本文转自:http://www.511yj.com/centos-yum-kernel.html 今天想在centos6.5安装docker,在网上查了说centos6.5需要64位的,内核需要升级到 ...