Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: handleOpenFile(ApplicationEvent) not being called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handleOpenFile(ApplicationEvent) not being called



BG wrote:

>java version "1.5.0_06"
>Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-112)
>Java HotSpot(TM) Client VM (build 1.5.0_06-64, mixed mode, sharing)
>
>With OS X 10.4.7 on an Intel Macbook. (2 GHz Intel Core Duo, 2GB memory).

I have a Java app that uses ApplicationListener, and it gets the
handleOpenFile() events just fine on a similar configuration:
  10.4.7, Java 1.5.0_06-112, i386 arch

My machine is a Core Duo Mac Mini, though.

My app's CFBundleDocumentTypes consists of a single entry for "all"
CFBundleTypeName, "Viewer" CFBundleTypeRole, and "****" for
CFBundleTypeOSTypes.


>I've tried putting code in as the first lines to display JOptionPanes when
>each of the methods are called and it *appears* that handleOpenFile()
>isn't being called at all, whereas handleOpenApplication() is.

It can be unwise to block a handler by showing a JOptionPane.
What does something more primitive, a System.err.println(), show?


>If I drop it onto the dock or finder icons for the app, it brings that
>copy of the application to the front, but it doesn't open up the file.

I don't recall seeing that happen unless there's something wrong in the
handler itself, such as an unchecked exception being thrown but not caught.
Temporarily replace your existing handler with this:

public void
handleOpenFile(ApplicationEvent event )
{
  try
  {
    System.err.println( event.getFilename() );

      // Put other code here later, but get this simple handler working first.

    event.setHandled( true );
  }
  catch ( Throwable caught )
  {  caught.printStackTrace(); }
}

Then look in console log for any output at all.

  -- GG


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

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 © 2011 Apple Inc. All rights reserved.