Results 1 to 6 of 6
  1. #1
    cruxblack is offline Senior Member
    Join Date
    Jul 2007
    Posts
    130
    Rep Power
    0

    Default Adding listener to non-Java object?

    Ellow all :)
    Wanna ask, im trying to make a tracker program that collects data about how many time an icon, folder(directory) or file in my computer had been accessed today, and if it has been clicked or accessed more than n times today, the program would send a response by redirecting the folder destination to another explicit destination folder that i have provided

    The only idea i get is to add listener to the file or folders, to get what actions have been done to the object, and then submit it to my program which will then give orders on what to do if a certain conditions are meet

    What im not sure, whether is there any way to add listener to objects not created using Java, like folders or files or window-frames in Windows?
    So far all i know is adding listener to objects created as Java Component

    For file, im not familiar with the File class so i haven't tried it, but just a thought, the idea is to derived the File class and implements a listener to it's subclass so that it'll listen to the real file situation, but i just wonder, will it listen in real-time execution?
    So far from my knowledge, File class are able to get File data, but mouse clicks and accessed report im not sure

    Anyone can help?
    Thanks :D
    CruxBlack

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    Your going to have to write a COM or .Net application to do this. This will require native hooks in Windows Explorer or the file system. I know you can create a COM object that can listen to file folder events and do things to them but, with Java this cannot be done.

  3. #3
    cruxblack is offline Senior Member
    Join Date
    Jul 2007
    Posts
    130
    Rep Power
    0

    Default

    So...Java is limited to its component alone?:confused:
    If so, what's the closest thing i can do to implement the problem using Java then?
    How bout in Linux then, could Java do it?

  4. #4
    levent Guest

    Default

    I dont know availability of operating system depending functionality. But if it is available in Windows, i think it should be available in Linux too.

    I don't think extending Java File class will work. You will need to write this functionality in native code (e.g. C, C++) and access to it from Java using JNI. I have done a Linux/Windows interface to a mathematics library. This is not difficult! But as always, you will need to spend time to learn JNI initially.

  5. #5
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    Java just isn't suited for this kind of problem. You can, as levent suggested, use JNI but you will find that in your case 90% of the code will be native and 10% will be Java. At that point it is easier to just use 100% native code.

    One option you may want to look at is to create a Windows Explorer in Java. Then you can track what is going on in Java. I'm willing to bet that there is a Java File Explorer already out there if you Google for it.

  6. #6
    cruxblack is offline Senior Member
    Join Date
    Jul 2007
    Posts
    130
    Rep Power
    0

    Default

    Oh, well ill try looking for it :(
    Thanks for the info guys :D

Similar Threads

  1. Replies: 2
    Last Post: 11-26-2010, 03:12 AM
  2. add an undo listener to a Jtable
    By christina in forum Advanced Java
    Replies: 12
    Last Post: 01-29-2009, 08:47 AM
  3. Listener for JFrame size change
    By Thez in forum AWT / Swing
    Replies: 10
    Last Post: 02-14-2008, 04:10 PM
  4. Listener for SWT event
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 10:04 AM
  5. Listener collision on game
    By cachi in forum Java Applets
    Replies: 1
    Last Post: 08-07-2007, 08:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •