Skip to main content

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

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

Back to the top