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

Eirik Bakke <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <D371DAAF.56FDE%[email protected]>
Beware that InputMap objects are often shared between different instances
of a Swing component. So modifying an InputMap that you didn't create
yourself can affect components that you maybe didn't intend to affect. I
usually always use a new InputMap that has the old one as a parent.

-- Eirik

On 5/29/16, 4:44 PM, "Klaus Martinschitz" <[email protected]>
wrote:

>O.K., I did it. I made a mistake.
>It should look like this...
>
>
>Code:
>InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW);
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_S, 0), "select");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_R, 0), "rotate");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD,
>KeyEvent.SHIFT_DOWN_MASK), "rotatePhi1Positive");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD,
>KeyEvent.CTRL_DOWN_MASK), "rotatePhiPositive");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD,
>KeyEvent.ALT_DOWN_MASK), "rotatePhi2Positive");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT,
>KeyEvent.SHIFT_DOWN_MASK), "rotatePhi1Negative");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT,
>KeyEvent.CTRL_DOWN_MASK), "rotatePhiNegative");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT,
>KeyEvent.ALT_DOWN_MASK), "rotatePhi2Negative");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
>"escape");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, 0), "zoom");//NOI18N
>     
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0),
>"selectFirstStereographicaReflexProvider");//NOI18N
>inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0),
>"selectSecondStereographicaReflexProvider");//NOI18N
>setInputMap(WHEN_IN_FOCUSED_WINDOW, inputMap);
>
>
>
>
>I didn't use WHEN_IN_FOCUSED_WINDOW.
>
>Now it works.
>
>Thanks again for your 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.