Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Awesomeness

macrumors member
Original poster
Feb 12, 2009
73
0
In application events, how do I detect when my application receives focus? As in its menu is in the top left corner?
 
A little browsing of the API does you a lot of good. More specifically, you need to implement WindowFocusListener in your event handler class. This interface lives in java.awt.event, and contains 2 methods: void windowGainedFocus(WindowEvent) and void windowLostFocus(WindowEvent).
 
A little browsing of the API does you a lot of good. More specifically, you need to implement WindowFocusListener in your event handler class. This interface lives in java.awt.event, and contains 2 methods: void windowGainedFocus(WindowEvent) and void windowLostFocus(WindowEvent).

I knew about that, but I didn't think it would work because sometimes all of the windows of my application will be hidden. I want it to show the hidden windows when my application gains focus.
 
I knew about that, but I didn't think it would work because sometimes all of the windows of my application will be hidden. I want it to show the hidden windows when my application gains focus.
Do you have an offscreen window, to handle the case when all windows are closed but the application should remain open, on the Mac OS? If you do, then attach the handler to that offscreen window.
 
Do you have an offscreen window, to handle the case when all windows are closed but the application should remain open, on the Mac OS?

I know, that's my problem... I've tried setting the location to negative and way positive, but Macs won't let you put the window offscreen. Is there some other method to get windows offscreen, or is it something else entirely, like a virtual window? I've looked through the API for an hour and found nothing... :(
 
I know, that's my problem... I've tried setting the location to negative and way positive, but Macs won't let you put the window offscreen. Is there some other method to get windows offscreen, or is it something else entirely, like a virtual window? I've looked through the API for an hour and found nothing... :(

Post your code. It should be enough code that someone else can compile and run it, not simply excerpts of what you think is relevant.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.