Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Start Swing app after users log in but minimized



Nicolae Cismaru wrote:

>2. If I do the same thing for my Java/Swing application, the splash screen
>and the main window are still displayed.

I just tried it here, on some bundled Java apps of my own, and you're right:
  the state of Hide has no effect.

Clearly, this is broken.  Please file a bug-report:
  <http://developer.apple.com/bugreporter>

Maybe this is one reason that LimeWire has a separate login-launcher app.
I think LimeWire's source is available, so you might want to use it as an
example to follow.


>But the problem now is different. How will I know if the application is
>started automatically at log in and not explicitly by the user?
>
>- If the application is started automatically and the Hide key is set to
>true, the splash and main window will not be displayed.
>
>- If it is started by the user, they must be displayed

Yes, that's a problem.

Given the Hide problem as well, let me outline a work-around.

Suppose your main app-bundle contained an embedded app-bundle, which is
just the login item auto-launcher.  If it's configured as a LSUIElement
(google for that, or search the list archives), it will not receive a
menu-bar or Dock icon.  Furthermore, if it doesn't display any windows, it
won't show any GUI, and the user simply won't see it.

What the auto-launcher app will have to do is check the state of its OWN
Hide key, and then launch your main app appropriately.  The way to launch
the main app is to launch it, then use 'osascript' to run a script that
tells the main app to hide itself.  The end result will be your main app
running, with a Dock icon, but hidden.  The auto-launcher can then exit.

I just did some tests, and here's a script fragment:

  tell application "System Events" to set visible of  <line-continues>
    (every application process whose name is "Foo") to false

where "Foo" is the name your main app has.

Alternatively, the auto-launcher app can be an AppleScript application
itself, and that might be a better path than writing another Java app that
exec()'s the 'osascript' command.

You can write AppleScript apps using Xcode.  It's pretty straightforward.

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.