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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:09:34+00:00 2026-05-15T02:09:34+00:00

I looked through ApplicationListener , and they don’t have it in there. On a

  • 0

I looked through ApplicationListener, and they don’t have it in there. On a Mac, it’s when that application has the equivalent of focus; its menu is in the top menu bar.

Also, if you know this, could you tell me how my application can request to de-focus itself?

  • 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-05-15T02:09:34+00:00Added an answer on May 15, 2026 at 2:09 am

    Implementations of windowActivated() and windowDeactivated() in WindowListener or WindowAdapter will tell you when a window is activated or deactivated. You don’t need ApplicationListener for that.

    Addendum: Although not required in this case, a transparent implementation of the additional functionality specified in ApplicationListener may be found in this example.

    Addendum: See also How to Write Window Listeners.

    Addendum: I think I see what you mean. In the example OSXAdapter, which uses -Dapple.laf.useScreenMenuBar=true, the menus disappear when the last window (HIDE_ON_CLOSE by default) closes. It’s less than optimal, but the About… and Preferences menus remain in the application menu; choosing either restores the screen menu. Another possibility is to modify the dock menu in com.apple.eawt.Application.

    import java.awt.EventQueue;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowFocusListener;
    import java.awt.event.WindowListener;
    import java.awt.event.WindowStateListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    
    public class WindowTest extends JFrame implements ActionListener,
        WindowListener, WindowFocusListener, WindowStateListener {
    
        public static final void main(String args[]) throws Exception {
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new WindowTest("One");
                    new WindowTest("Two");
                }
            });
        }
    
        public WindowTest(String name) {
            super(name);
            this.setName(name);
            this.setLayout(new GridLayout(0, 1));
            createButton("Back");
            createButton("Front");
            createButton("Hide");
            this.addWindowListener(this);
            this.addWindowFocusListener(this);
            this.addWindowStateListener(this);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setLocationRelativeTo(null);
            this.pack();
            this.setVisible(true);
        }
    
        private void createButton(String name) {
            JButton b = new JButton(name);
            this.add(b);
            b.addActionListener(this);
        }
    
        @Override
        public void actionPerformed(ActionEvent e) {
            String s = e.getActionCommand();
            if ("Back".equals(s)) {
                this.toBack();
            } else if ("Front".equals(s)) {
                this.toFront();
            } else {
                this.setExtendedState(JFrame.ICONIFIED);
            }
        }
    
        @Override
        public void windowOpened(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowClosing(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowClosed(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowIconified(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowDeiconified(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowActivated(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowDeactivated(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowGainedFocus(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowLostFocus(WindowEvent e) {
            System.out.println(e);
        }
    
        @Override
        public void windowStateChanged(WindowEvent e) {
            System.out.println(e);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've looked through several posts but I haven't quite found any answers that have
Disclaimer: I have looked through this question and this question but they both got
I have read looked through some code that implements tabs on the bottom of
I looked through the related questions, there were quite a few but I don't
have looked through many posts here on SO, and haven't found any that address
I looked through some code and noticed that the convention was to turn pointer
I looked through the Django built-in Auth app and noticed that views are split
I have looked through the other questions on here, and on other forums. The
I have looked through the documentation but cannot seem to find the answer. Suppose
I looked through the related questions and couldn't find anything that addresses exactly what

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.