users
[Top] [All Lists]

Re: [cinjug-users] KeyStroke and JScrollPane

To: users@xxxxxxxxxx
Subject: Re: [cinjug-users] KeyStroke and JScrollPane
From: Brian K Bonner <brian.bonner@xxxxxxxxxxxx>
Date: Tue, 21 Dec 2004 22:13:36 -0500
Delivered-to: mailing list users@cinjug.org
In-reply-to: <41C77E8C.8030307@Fuse.net>
Mailing-list: contact users-help@cinjug.org; run by ezmlm

Jim,

A1:  Assuming your scrollpane is declared as myScrollPane, then:

InputMap inputMap = myScrollPane.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
// actionKey is most likely a string -- this is a key into the ActionMap
Object actionKey = inputMap.get(KeyStroke.getKeyStroke("PAGE_UP"));
// Where "A" is the alternate keystroke that you want to bind
inputMap.put(KeyStroke.getKeyStroke("A"),actionKey);  

Should do the trick.  I just tried it out.

A2:  InputMap is a Map which maps the actual keystroke to an ActionKey, a key to find a specific action in an ActionMap.

Think of it as two related maps:

INPUT MAP
KEYSTROKE ACTIONKEY
Keystroke("PAGE_UP") "scrollUp"


       
ACTIONMAP  (using the ActionKey from InputMap)
ACTIONKEY ACTION
"scrollUp" ActionInstance


HTH,

Brian




James Hurt <JimHurt@xxxxxxxx> wrote on 12/20/2004 08:38:20 PM:

> I have need to use different key strokes than the default to scroll around a
> JScrollPane.  That is, I need to use certain keys such as Page_Up to mean
> something different than scroll the JScrollPane one block up.  My problem is
> that JScrollPane is capturing the Page_Up key strokes and not
> passing them on to
> my code.
>
> Q1: How do I change the scrolling key settings for JScrollPane from
> the default
> to something I specify?
>
> Q2: What is the difference between an InputMap and an ActionMap?  
> When do I use
> one and not the other?
>
> Jim Hurt
>
>
>
>
> ---------
> You may unsubscribe from this mailing list
> by sending a blank email addressed to:
> users-unsubscribe@xxxxxxxxxx
>
> --
> Find additional help by sending a blank email
> addressed to:
> users-help@xxxxxxxxxx
>
<Prev in Thread] Current Thread [Next in Thread>