Posted on 2012-05-30 19:47
penngo 阅读(2337)
评论(0) 编辑 收藏 所属分类:
Java
很久没写日志了,在窗口不是活动窗口时,类似QQ来信息时在任务栏的窗口闪动效果,实现代码,
package com.pengo;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class JFrameTest {
private JFrame frame = null;
public JFrameTest() {
frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowDeactivated(WindowEvent e) {
frame.setVisible(true);
}
});
}
public static void main(String[] args) {
new JFrameTest();
}
}