Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8636517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:14:45+00:00 2026-06-12T10:14:45+00:00

I know how to place an icon in window’s systray using java, But what

  • 0

I know how to place an icon in window’s systray using java, But what the best method to perform systray icon Blinking? or if I can replace any icon time to time or at some event (while the application is running),
Kindly share your experiences thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:14:47+00:00Added an answer on June 12, 2026 at 10:14 am
    • there no issue to change Icon on some bases with output as blinking Icon

    • create an Arrays of BufferedImage or Queue

    • start Swing Timer on desired event and change BufferedImage or Icons on some period

    • and to stop Swing Timer after some time remained or add ActionListener to the Message, another way could be determine LEFT or RIGHT mouse button from MouseListener ( for Icon in System Tray) one for stop of Timer, second for JPopup

    EDIT

    for example, as I mentioned you can add ActionListener or MouseListener, there you can to stop Swing Timer

    import java.awt.AWTException;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GraphicsConfiguration;
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
    import java.awt.Image;
    import java.awt.MenuItem;
    import java.awt.PopupMenu;
    import java.awt.SystemTray;
    import java.awt.TrayIcon;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.SwingUtilities;
    import javax.swing.Timer;
    import javax.swing.UIManager;
    
    public class ActiveTray {
    
        private SystemTray tray;
        private TrayIcon trayIcon;
        private Icon icon, icon1;
        private Image image, image1;
        private Timer timer;
    
        public ActiveTray() {
            if (SystemTray.isSupported() == false) {
                System.err.println("No system tray available");
                return;
            }
            tray = SystemTray.getSystemTray();
            PropertyChangeListener propListener = new PropertyChangeListener() {
    
                public void propertyChange(PropertyChangeEvent evt) {
                    TrayIcon oldTray[] = (TrayIcon[]) evt.getOldValue();
                    TrayIcon newTray[] = (TrayIcon[]) evt.getNewValue();
                    System.out.println(oldTray.length + " / " + newTray.length);
                }
            };
            tray.addPropertyChangeListener("trayIcons", propListener);
            icon = new BevelArrowIcon(BevelArrowIcon.UP, false, false);
            image = iconToImage(icon);
            icon1 = new BevelArrowIcon(BevelArrowIcon.DOWN, false, false);
            image1 = iconToImage(icon1);
            PopupMenu popup = new PopupMenu();
            MenuItem item = new MenuItem("Hello, World");
            trayIcon = new TrayIcon(image, "Tip Text", popup);
            ActionListener menuActionListener = new ActionListener() {
    
                public void actionPerformed(ActionEvent e) {
                    trayIcon.displayMessage("Good-bye", "Cruel World",
                            TrayIcon.MessageType.WARNING);
                }
            };
            item.addActionListener(menuActionListener);
            popup.add(item);
            ActionListener actionListener = new ActionListener() {
    
                public void actionPerformed(ActionEvent e) {
                    tray.remove(trayIcon);
                }
            };
            trayIcon.addActionListener(actionListener);
            try {
                tray.add(trayIcon);
                start();
            } catch (AWTException ex) {
                Logger.getLogger(ActiveTray.class.getName()).log(Level.SEVERE, null, ex);
            }
    
        }
    
        private void start() {
            timer = new javax.swing.Timer(125, updateCol());
            timer.start();
            trayIcon.displayMessage(null, "  Aplication Loaded  ", TrayIcon.MessageType.NONE);
        }
    
        private Action updateCol() {
            return new AbstractAction("Icon load action") {
    
                private static final long serialVersionUID = 1L;
    
                @Override
                public void actionPerformed(ActionEvent e) {
                    Runnable doRun = new Runnable() {
    
                        @Override
                        public void run() {
                            Image img = trayIcon.getImage();
                            if (img == image) {
                                trayIcon.setImage(image1);
                            } else {
                                trayIcon.setImage(image);
                            }
                        }
                    };
                    SwingUtilities.invokeLater(doRun);
                }
            };
        }
    
        public static void main(String args[]) {
            ActiveTray activeTray = new ActiveTray();
        }
    
        static Image iconToImage(Icon icon) {
            if (icon instanceof ImageIcon) {
                return ((ImageIcon) icon).getImage();
            } else {
                int w = icon.getIconWidth();
                int h = icon.getIconHeight();
                GraphicsEnvironment ge =
                        GraphicsEnvironment.getLocalGraphicsEnvironment();
                GraphicsDevice gd = ge.getDefaultScreenDevice();
                GraphicsConfiguration gc = gd.getDefaultConfiguration();
                BufferedImage image = gc.createCompatibleImage(w, h);
                Graphics2D g = image.createGraphics();
                icon.paintIcon(null, g, 0, 0);
                g.dispose();
                return image;
            }
        }
    
        static class BevelArrowIcon implements Icon {
    
            public static final int UP = 0;         // direction
            public static final int DOWN = 1;
            private static final int DEFAULT_SIZE = 16;
            private Color edge1;
            private Color edge2;
            private Color fill;
            private int size;
            private int direction;
    
            public BevelArrowIcon(int direction, boolean isRaisedView,
                    boolean isPressedView) {
                if (isRaisedView) {
                    if (isPressedView) {
                        init(UIManager.getColor("controlLtHighlight"),
                                UIManager.getColor("controlDkShadow"),
                                UIManager.getColor("controlShadow"),
                                DEFAULT_SIZE, direction);
                    } else {
                        init(UIManager.getColor("controlHighlight"),
                                UIManager.getColor("controlShadow"),
                                UIManager.getColor("control"),
                                DEFAULT_SIZE, direction);
                    }
                } else {
                    if (isPressedView) {
                        init(UIManager.getColor("controlDkShadow"),
                                UIManager.getColor("controlLtHighlight"),
                                UIManager.getColor("controlShadow"),
                                DEFAULT_SIZE, direction);
                    } else {
                        init(UIManager.getColor("controlShadow"),
                                UIManager.getColor("controlHighlight"),
                                UIManager.getColor("control"),
                                DEFAULT_SIZE, direction);
                    }
                }
            }
    
            public BevelArrowIcon(Color edge1, Color edge2, Color fill,
                    int size, int direction) {
                init(edge1, edge2, fill, size, direction);
            }
    
            @Override
            public void paintIcon(Component c, Graphics g, int x, int y) {
                switch (direction) {
                    case DOWN:
                        drawDownArrow(g, x, y);
                        break;
                    case UP:
                        drawUpArrow(g, x, y);
                        break;
                }
            }
    
            @Override
            public int getIconWidth() {
                return size;
            }
    
            @Override
            public int getIconHeight() {
                return size;
            }
    
            private void init(Color edge1, Color edge2, Color fill,
                    int size, int direction) {
                edge1 = Color.red;
                edge2 = Color.blue;
                this.edge1 = edge1;
                this.edge2 = edge2;
                this.fill = fill;
                this.size = size;
                this.direction = direction;
            }
    
            private void drawDownArrow(Graphics g, int xo, int yo) {
                g.setColor(edge1);
                g.drawLine(xo, yo, xo + size - 1, yo);
                g.drawLine(xo, yo + 1, xo + size - 3, yo + 1);
                g.setColor(edge2);
                g.drawLine(xo + size - 2, yo + 1, xo + size - 1, yo + 1);
                int x = xo + 1;
                int y = yo + 2;
                int dx = size - 6;
                while (y + 1 < yo + size) {
                    g.setColor(edge1);
                    g.drawLine(x, y, x + 1, y);
                    g.drawLine(x, y + 1, x + 1, y + 1);
                    if (0 < dx) {
                        g.setColor(fill);
                        g.drawLine(x + 2, y, x + 1 + dx, y);
                        g.drawLine(x + 2, y + 1, x + 1 + dx, y + 1);
                    }
                    g.setColor(edge2);
                    g.drawLine(x + dx + 2, y, x + dx + 3, y);
                    g.drawLine(x + dx + 2, y + 1, x + dx + 3, y + 1);
                    x += 1;
                    y += 2;
                    dx -= 2;
                }
                g.setColor(edge1);
                g.drawLine(xo + (size / 2), yo + size - 1, xo
                        + (size / 2), yo + size - 1);
            }
    
            private void drawUpArrow(Graphics g, int xo, int yo) {
                g.setColor(edge1);
                int x = xo + (size / 2);
                g.drawLine(x, yo, x, yo);
                x--;
                int y = yo + 1;
                int dx = 0;
                while (y + 3 < yo + size) {
                    g.setColor(edge1);
                    g.drawLine(x, y, x + 1, y);
                    g.drawLine(x, y + 1, x + 1, y + 1);
                    if (0 < dx) {
                        g.setColor(fill);
                        g.drawLine(x + 2, y, x + 1 + dx, y);
                        g.drawLine(x + 2, y + 1, x + 1 + dx, y + 1);
                    }
                    g.setColor(edge2);
                    g.drawLine(x + dx + 2, y, x + dx + 3, y);
                    g.drawLine(x + dx + 2, y + 1, x + dx + 3, y + 1);
                    x -= 1;
                    y += 2;
                    dx += 2;
                }
                g.setColor(edge1);
                g.drawLine(xo, yo + size - 3, xo + 1, yo + size - 3);
                g.setColor(edge2);
                g.drawLine(xo + 2, yo + size - 2, xo + size - 1, yo + size - 2);
                g.drawLine(xo, yo + size - 1, xo + size, yo + size - 1);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanna know where is the best place to put the ini_set() functions, because
I don't know if this is the place to ask this question, but if
Ok I know jquery can do this pretty simply, but digging around I'm a
I want to set an icon for my application in Java. I'm using Eclipse.
I know I can add a icon to the Resources.resx file of a project
I've done this before, and know it's pretty simple - but can't remember. How
I know the ideal place to ask is at . I posted my question
Does anyone know a good place to look for basic principles and tutorials on
Does anybody know a good place to learn how to use the debugger in
I just wanted to know if I need to place a check for null

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.