tags:

views:

29

answers:

1

I need to change the behavior of every JButton in an application (it's a research project). We felt that the best way to change all of the buttons using an aspect since it would keep it clean--we wouldn't have to change all 262 instances to a new type. We have run into a snag. The aspect that we have written does not modify the buttons in a JOptionPane like it does for every other button in our project. Here is the advice that I have:

after() returning(JButton button): call(*.new(..)) || call(* newInstance(..)) {
    init(button);
}

This matches every other constructor of JButton, but it seems to be missing the one used by JOptionPane. How can I access their creation? I'm still new at AOP, so maybe this isn't even possible to do.

A: 

I think AspectJ ignores the javax package by default. Since the option pane buttons are created in the look and feel code (see BasicOptionPaneUI.ButtonFactory in the javax.swing.plaf.basic package for example), that might be why it's being ignored. Maybe look at changing the configuration options to allow/include the javax package?

Ash
That explanation surely makes sense. I'll have to try to figure out how I can make it weave into the `javax` package tomorrow when I go in. Thanks for the tip!
geowa4