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 8658541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:47:35+00:00 2026-06-12T15:47:35+00:00

I made a java swing application, and it needs to run on Windows as

  • 0

I made a java swing application, and it needs to run on Windows as well as Mac OS X.

When the user clicks on the minimize button, the application is minimized, and an icon is created in system tray with the following code:

MainScreen.getInstance().setExtendedState(JFrame.ICONIFIED);

trayIcon = new TrayIcon(new ImageIcon(getClass().getResource(
       "/dragonstore/resources/icon.png")).getImage());

trayIcon.setToolTip("DragonStore");
trayIcon.setImageAutoSize(true);
trayIcon.addMouseListener(new MouseAdapter()
{
     @Override
     public void mouseClicked(MouseEvent e)
           {
           MainScreen.getInstance().setVisible(true);

           MainScreen.getInstance().setExtendedState(NORMAL);
           SystemTray.getSystemTray().remove(trayIcon);
           trayIcon=null;
           MainScreen.getInstance().toFront();
           MainScreen.getInstance().getMainPanel().revalidate();
           MainScreen.getInstance().getMainPanel().repaint();
           MainScreen.getInstance().pack();
           MainScreen.getInstance().validate();
           MainScreen.getInstance().repaint();
           System.out.println("Restore");
       }
});
SystemTray.getSystemTray().add(trayIcon);
trayIcon.displayMessage("DragonStore",
        "Click here to maximized window again",TrayIcon.MessageType.INFO);
setVisible(false);

So above code executes fine, and when the user clicks on the system tray icon, the application is restored by the code in trayIcon Mouse Clicked function.

Every thing goes fine on Windows with no problems anywhere.

But on Mac OS X when I restore the application, it appears with all components in animated style which is default on Mac, but once it fully restores on screen the window displays a blank window, as if the frame had no components.

I looked into the problem and found a redraw of frames bug in Mac OS X Lion, but I do not expect it is the issue here.

What should I do to solve this?

My objective is to make minimized applications be invisible from the task bar and the icon shows up in a system tray notification, so the user can restore the application by clicking on system tray icon.

It must be executed both on Windows and Mac.

enter image description here

Thanks

  • 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-12T15:47:36+00:00Added an answer on June 12, 2026 at 3:47 pm
    What should I do to solve this?
    

    use

    1. JFrame#setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); instead of MainScreen.getInstance().setExtendedState(JFrame.ICONIFIED);

    2. MainScreen.getInstance().setVisible(true); should be last line (and only one code line) in public void mouseClicked(MouseEvent e), every code lines are useless, because JFrame.HIDE_ON_CLOSE only to hide JFrame,

    3. Every thing goes fine on Windows with no problems anywhere. I doubt …, but for better help sooner post an SSCCE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a Java Swing application. Now I would like to make it
I had made one Java Swing based application. On my application,if i click anywhere
I had made one application in java-swing, Now what i am getting problem is,
Hi I made a java swing application. Also created jar of that file. Now
I made a java swing application, but now I need some functionality for backup
I have made a small java swing application that I want to share with
I have made a java swing GUI. Now I want to display a static
In the Java Swing app I made it seems to me that all the
I have made a java application and have packed it into an executable jar
I have made a java application that stores data from a .csv file to

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.