日期:2014-05-20 浏览次数:20683 次
** * 原理就是当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 ); }