开发者

How to change the buttons in a JOptionPane using AspectJ

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 aspe开发者_StackOverflowct 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.


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜