从网上找到的。 ** * 原理就是当Iframe不是焦点时,<br> * 使用setVisible(true)对他再次显示<br> * 就会有闪烁效果 * @author 飞雪无情 * */ public class JFrameTest { private JFrame frame = null; public JFrameTest() { frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 300); frame.setVisible(true); try { // 这里等待3秒钟,你打开其程序, //主要目的是使frame不是当前的聚焦窗体 Thread.sleep(3000); }catch (InterruptedException e1){ e1.printStackTrace(); } frame.setVisible(true); } /** * @param args */ public static void main(String[] args) { new JFrameTest(); }}
/** * Flashes the specified window. It does not change the active state of the * window. * * @param hwnd * specified window handle. * @param flash * whether flash the window. * @return return true if do the operation successfully, else return false. * */ public static boolean flashWindow( int hwnd, boolean flash ) { FLASHWINFO flashInfo = new FLASHWINFO( ); if ( flash ) flashInfo.dwFlags = FLASHWINFO.FLASHW_ALL | FLASHWINFO.FLASHW_TIMER; flashInfo.hwnd = hwnd; return Extension.FlashWindowEx( flashInfo ); }
我的思路如下:1.应用java.swing.Timer类每隔多少秒执行一下刷新函数
2.刷新函数: 可以定义一个boolean,调试时改变其值,根据真假切换不同的任务栏图标(或者说是图片)(原来的图标,和透明的图标)
只是我的设想,不知是否可行
**
* 原理就是当Iframe不是焦点时,<br>
* 使用setVisible(true)对他再次显示<br>
* 就会有闪烁效果
* @author 飞雪无情
*
*/
public class JFrameTest {
private JFrame frame = null;
public JFrameTest() {
frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
try {
// 这里等待3秒钟,你打开其程序,
//主要目的是使frame不是当前的聚焦窗体
Thread.sleep(3000);
}catch (InterruptedException e1){
e1.printStackTrace();
}
frame.setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
new JFrameTest();
}}
/**
* Flashes the specified window. It does not change the active state of the
* window.
*
* @param hwnd
* specified window handle.
* @param flash
* whether flash the window.
* @return return true if do the operation successfully, else return false.
*
*/
public static boolean flashWindow( int hwnd, boolean flash )
{
FLASHWINFO flashInfo = new FLASHWINFO( );
if ( flash )
flashInfo.dwFlags = FLASHWINFO.FLASHW_ALL | FLASHWINFO.FLASHW_TIMER;
flashInfo.hwnd = hwnd;
return Extension.FlashWindowEx( flashInfo );
}