[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Weaving into JOptionPane

Unfortunately, you will not be able to directly advise JButtons
created inside of the swing library unless you weave into the swing
library itself (not really something I recommend).

The best thing that I can think of is finding out where the JButtons
are created and target your advice for the location in your code that
indirectly constructs these extra JButtons.  Then you must get a
handle on these new JButtons in order to initialize them.

However, briefly looking at the swing code and it seems like these
extra JButtons are constructed in several places deep within swing
code.  So, it may be challenging.  I wish I could be more help.

--a

On Mon, Jul 26, 2010 at 11:32 AM, George Adams <g.w.adams.iv@xxxxxxxxx> wrote:
> I have inherited an old code-base, and we wanted to change the behavior of
> every JButton that is ever created. I am new to AOP, but I have something
> that catches almost every JButton that is created. The only ones left out
> are the ones that are in JOptionPanes. How do I write an aspect that will
> catch the JButtons that are created in JOptionPanes? All I want to do is add
> a few listeners to the newly created button.
> Here is what I have so far:
> public aspect AccessibleButton {
> ...
>         private FocusListener listener = new FocusListener() {...}
>         private void init(JButton button) {
>                 ...
> }
>         after() returning(JButton button): call(*.new(..)) || call(*
> newInstance(..)) {
>                 init(button);
>         }
> }
> I feel like I'm close. I just can't figure out what I'm missing, and I don't
> feel like creating a custom JOptionPane implementation.
> Thanks in advance!
> --
> George Wright Adams IV
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>