Am I using the InputMap and the ActionMap correctly?

"Klaus Martinschitz" <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <[email protected]>
Hello,

till now I did not have to deal with InputMaps and ActionMaps. However, I figured out that they are really cool and can improve the code immensely.

My situation is as following:

I have designed a Swing panel in a standard plain Java project. Absolutely no connection to Netbeans Platform. It is part of a library that should also work for WebStart. So, I had my panel, I defined ActionMap and InputMap inside my JPanel and I could test the Panel with a standard JFrame architecture.

No, I want this JPanel to be child of a TopComponent. I created wrapper and all that stuff and implemented it. Everything worked perfectly. However, everything except the keybindings that didn't work anymore. I tried many solutions, until I had the idea to take the InputMap and ActionMap from the JPanel child component and put it to my TopComponent in the following method...


Code:
@Override
    public void componentActivated() {
        setActionMap(stereographicaProjectionPanel.getActionMap());
        setInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,stereographicaProjectionPanel.getInputMap());
    }




I have got two questions.
First question is, if this strategy is correct.
Second question is if there is a way to tell the TopComponent that it should merge the ActionMaps and InputMaps from its child components automatically. I am not sure if this is desired or would even cause problems. Perhaps I just understand the keybinding architecture not yet well enough.

Thanks a lot for help.

Regards,
Klaus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.