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
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());
}
}
}
}