package com.usc.base.JFrame;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JWindow;
import com.sun.awt.AWTUtilities;
import com.usc.base.JLabel.BaseLabel;
/**
* @author 作者:Sky_in_night
* @date 创建时间:2018年2月15日 下午4:31:00
* @ProjectName 项目名称:HappyNewYear
* @FileName 文件名称:com.usc.base.JFrame.BaseFrame.java
*
*/
public class BaseWindow extends JWindow {
/**
*
*/
private static final long serialVersionUID = 1L;
private float alpha = 0;
private static float MAX_VIRT = 1.0f;// 窗体透明程度
private static float STEP_WEDITH = 0.01f;// 窗体渐变幅度
private static int RUN_TIME = 15;// 每次执行线程时的间隔时间
public BaseWindow(int width, int heigth, int x, int y, String character, int time) {
com.sun.awt.AWTUtilities.setWindowOpacity(this, 0.0f);
// 插入字体,一定要先插入,不然会直接显示不出来,除非是图片。
add(new BaseLabel(character));
// 设置窗体背景颜色为透明
AWTUtilities.setWindowOpaque(this, false);
// 设置窗体大小
setSize(width, heigth);
// 设置窗体位置
setLocation(x, y);
// 显示窗体
setVisible(true);
// 淡入窗体
showWindow(time);
}
/**
* 显示窗体的函数,有渐渐淡入的特效
*
* @param startTime
* 开始显示窗体的时间
*/
public void showWindow(int startTime) {
new Timer().schedule(new MyTaskShow(this), startTime);
}
/**
* 窗体显示特效的任务对象
*
* @author Sky_in_night
*
*/
private class MyTaskShow extends TimerTask {
BaseWindow bw;
public MyTaskShow(BaseWindow bw) {
super();
this.bw = bw;
}
@Override
public void run() {
// 判断是否到达最大实体值如果没有继续显现
while (alpha < MAX_VIRT - STEP_WEDITH) {
alpha = alpha + STEP_WEDITH;
com.sun.awt.AWTUtilities.setWindowOpacity(bw, alpha);
try {
Thread.sleep(RUN_TIME);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
最近下载更多
阿远远 LV8
2019年12月12日
simple丶余心 LV21
2019年10月30日
dengss LV11
2019年5月10日
ZKsrw丶 LV4
2018年10月28日
caiyingwenwang LV18
2018年8月16日
陌上花开AAA LV4
2018年7月11日
Dvvvv123qwe LV6
2018年7月3日
hongdalao LV1
2018年5月4日
1165343269 LV1
2018年4月21日
yangbiao LV5
2018年4月13日

最近浏览