• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help using JDIC to register file associations

 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to find a way to use JDIC to associate a file type with a particular application, and it's not working for me. The ultimate goal is the I want a user to be able to be using, say, Windows Explorer, see a file, right click on it, and see an option pop up to invoke a particular program, passing the selected file as an argument. JDIC seems to support this, particularly according to this article. However in tests I've run so far, I haven't been able to observe it actually working. Here's some code I've tried:

The output I see (running on Windows 2000 Pro using JDIC 0.9.1) is:

Which is all well and good. The association did not exist initially (I chose .FOO as the filetype precisely because it is not associated with anything currently) and after calling registerAssociation, the association appears to exist - according to the Java program. Good.

Unfortunately, this appears to have no observable effect outside the JVM. Going to Explorer -> Tools -> Folder Options -> File types, I don't see an association listed for FOO files, or a description saying XXXXXX. If I right click or double click on a samlple file with a .FOO extension, I don't start up TextPad, nor see an option to open with TextPad. This appears to be true whether I let the Java program exist, or keep the main thread active with a prolonged sleep() call (shown commented out above). Closing Explorer and reopening it does not cause it to load new file associations, either.

So, does anyone have any ideas or suggestions on what I might be missing here? Thanks.
[ October 20, 2006: Message edited by: Jim Yingst ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are missing the following code:

 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
D'oh! That was one of the first pieces I put in (back before I found the article I referenced). Somehow as I was shifting things around, trying different things, I dropped that piece without realizing. Now it's working - well not perfectly yet, but enough that I'm sure I can twiddle with it until it's right. Maybe by, oh, copying that sample code verbatim this time? Other than the error handling of course. Thanks, Gregg.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jim Yingst:
D'oh! That was one of the first pieces I put in (back before I found the article I referenced). Somehow as I was shifting things around, trying different things, I dropped that piece without realizing. Now it's working - well not perfectly yet, but enough that I'm sure I can twiddle with it until it's right. Maybe by, oh, copying that sample code verbatim this time? Other than the error handling of course. Thanks, Gregg.



Hehe. No problem. The JDIC download has demo code with it. It's a swing app for doing the same thing. But that's where I noticed your missing piece.
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a random aside, Jim, but I thought i should mention it since you're using JDIC. If you want to use Balloons (those tool tips that pop up from a system tray icon) and you're on Windows 2000, you will not receive any events. For some reason it's an undocumented "feature" of win 2k that balloons don't send click events. (it's not just a JDIC issue)

I checked this against win2k service pack 2, 3 and 4. In the end, I had to write my own balloon tip class in order to react to a user clicking on the balloon.
reply
    Bookmark Topic Watch Topic
  • New Topic