import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Shixun5 extends JFrame{
private static final long serialVersionUID = -7296285942374144772L;
//获取面板对象
private JPanel panel = null;
//获取标签对象
private JLabel label = null;
//获取屏幕对象
private static final Dimension SCREENSIZE = Toolkit.getDefaultToolkit().getScreenSize();
//宽度
private static final int WIDTH = SCREENSIZE.width/2;
//高度
private static final int HEIGHT = 30;
public Shixun5(){

super();
//设置窗体不在任务栏显示
this.setType(Type.UTILITY);
this.panel = new JPanel();
//将消息显示在标签上
this.label = new JLabel("这是信息");
//使标签水平居中显示
this.label.setHorizontalAlignment(SwingConstants.CENTER);
//设置文字颜色为红色
this.label.setForeground(Color.RED);
//设置字体显示为宋体,加粗,字号50
this.label.setFont(new Font("宋体", Font.ROMAN_BASELINE, 11));
//设置文字最上显示
this.label.setOpaque(true);
//这是文字的背景颜色为白色
this.label.setBackground(Color.white);
double value = 0.2;
// 判断是否支持透明度
this.setUndecorated(true); // 禁用或启用此窗体的修饰。只有在窗体不可显示时
//才调用此方法。
if (com.sun.awt.AWTUtilities.isWindowOpaque(this)) {
com.sun.awt.AWTUtilities.setWindowOpacity(this, (float)(1 - value));
} else {
JOptionPane.showMessageDialog(this, "系统不支持 JDK版本过低或 JRE 系统库缺损");
}
//将标签添加到面板上
this.panel.add(label);
//讲面板添加到弹窗
this.add(label);
//设置弹窗的大小
this.setSize(WIDTH, HEIGHT);
//设置弹窗在屏幕显示的位置
//TODO 显示位置待定义,可以设置靠上显示,如贴紧上方的弹窗的边,若没有弹窗就贴紧屏幕上方
this.setLocation(WIDTH-WIDTH/2,HEIGHT*0);
//将弹窗的外边框去掉
this.setUndecorated(true);
//设置窗口默认显示
this.setVisible(true);
this.setAlwaysOnTop(true);
this.addMouseListener(new mLis(this));
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
class mLis extends MouseAdapter{
JFrame jFrame;
mLis(JFrame jFrame){
this.jFrame = jFrame;
}
public void mouseEntered(MouseEvent e){
jFrame.setSize(1,1);
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
jFrame.setSize(WIDTH, HEIGHT);
}
}
public static void main(String[]args){
new Shixun5();
}

}