Java如何在Swing中刷新窗口任务栏?
package org.nhooo.example.swing; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class WindowTaskbarFlash extends JFrame { private WindowTaskbarFlash() throws HeadlessException { initUI(); } private void initUI() { setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); pack(); setSize(200, 200); setState(Frame.ICONIFIED); //演示闪烁的应用程序窗口任务栏 //每5秒调用一次toFront方法。 Timer timer = new Timer(5000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toFront(); } }); timer.start(); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new WindowTaskbarFlash().setVisible(true); } }); } }