Re: Am I using the InputMap and the ActionMap correctly?

Benno Markiewicz <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <CAA_aP4gsO3beQ=f7q0X5BCbNGSz+7ZKm91WGZ52iE8uE4ZNOGg@mail.gmail.com>
Are you missing

associateLookup(ExplorerUtils.createLookup(em, getActionMap()));

?


With kind regards, markiewb

2016-05-25 15:42 GMT+02:00 Klaus Martinschitz <[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.