aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Filters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Filters" Watch "Filters" New topic
Author

Filters

Eddie Long
Ranch Hand

Joined: Nov 02, 2003
Posts: 69
Is it possible to apply the idea of filters to Swing event handlers? i.e. execute certain code before listnener code e.g. actionPerformed(ActionEvent event) and another piece of code after the listener has finished.

Thanks in advance


...and so help me God.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Moved to Swing.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Not really. I mean, the only way you can capture an event is in the actionPerformed method. You can do whatever you want in that method. So you could say Do A, Then B, Then C, just like in any other method. Where A and C were your before and after events?

What exactly are you trying to do? Maybe that will help clarify and we can come up with a viable solution for you.


GenRocket - Experts at Building Test Data
Eddie Long
Ranch Hand

Joined: Nov 02, 2003
Posts: 69
I'm looking for a way to insert services before and after events exactly like you would do for JSPs i.e. so i want to be know when my actionperformed method is going to be called and when it has been called.

the reason for not putting things in my actionperformed method is for the same as the reason you would use filters i.e. you don't want code that has nothing to do with the job of the servlet to clutter things in your doPost or doGet method

One way i could use is the awteventlistener which notifies you before an event is dispatched but i don't think there is any guarantee in the when the event will be dipatched after you've been notified. also there is nothing similar for when an event has been handled.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

I'm thinking you could use an AOP (aspect-oriented programming) tool like AspectJ to do this.


[Jess in Action][AskingGoodQuestions]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by Ernest Friedman-Hill:
I'm thinking you could use an AOP (aspect-oriented programming) tool like AspectJ to do this.


You know, I would have suggested that. But I have no idea what Aspect Oriented Programming is. Guess I should read up. Ahh, something else to put in my brain. I guess I'll have to see what knowledge is expendable.
Eddie Long
Ranch Hand

Joined: Nov 02, 2003
Posts: 69
Thanks. I'll have a look at AOP...

When does the learning stop and enjoying the fruits of ones labour start???
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by Eddie Long:
Thanks. I'll have a look at AOP...

When does the learning stop and enjoying the fruits of ones labour start???


You know that instant when you are just about to die and you see your life pass before your eyes? That's when.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filters