How do I flash the window taskbar in Swing?

package org.kodejava.swing;

import javax.swing.*;
import java.awt.*;

public class WindowTaskbarFlash extends JFrame {
    private WindowTaskbarFlash() throws HeadlessException {
        initUI();
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(
                () -> new WindowTaskbarFlash().setVisible(true));
    }

    private void initUI() {
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        pack();
        setSize(200, 200);
        setState(Frame.ICONIFIED);

        // Demonstrate flashes the application window task bar
        // by calling the toFront method every 5 seconds.
        Timer timer = new Timer(5000, e -> toFront());
        timer.start();
    }
}
Wayan

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.