This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filters

 
Eddie Long
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Swing.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eddie Long
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm thinking you could use an AOP (aspect-oriented programming) tool like AspectJ to do this.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I'll have a look at AOP...

When does the learning stop and enjoying the fruits of ones labour start???
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic