Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event without GUI

Status
Not open for further replies.

russland

Programmer
Jan 9, 2003
315
0
0
CH
Hi, I'm having a listener place which is listening to file changes on my local hard drive (using JNA). works nicely.

In this class (singleton), i check if this file is a pdf document (works fine to). If yes, I would like to raise an event that could be captured by another object of my application. I recongnized that the EventObject is located in the java.util library. that somehow implies it's supposed to be used by any object - not just AWT or Swing, isn't?

Writing an eventListener is clear, but how do I write the event? In this case, for finding a PDF file. I'm positive this is feasible.

Find below my inner-class fListener. Thanks for any hint or reference!

russ

Code:
private class fListener implements FileListener {
        @Override
        public void fileChanged(FileEvent fe) {
            if(fe.getFile().isFile()){
                //verify if it's a Adobe PDF document
                if( Pattern.matches(".+.PDF", fe.getFile().getName()) ){
                    //throw an event
                     System.out.println ("Adobe PDF: "+ fe.getFile().getAbsolutePath());
                }
            }
        }
    }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top