classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: JList key bindings reworked


From: Anthony Balkissoon
Subject: [cp-patches] FYI: JList key bindings reworked
Date: Mon, 17 Oct 2005 15:14:19 -0400

This patch implements InputMap-ActionMap pairs for JList and removes the
KeyAdapater that used to directly listen for key presses.  Also fixes
some bugs in selectNextIndex and selectPreviousIndex as well as in when
these methods were being called (slight bugs, they were called on the
wrong keyStrokes and didn't check if they were already at the lowest or
highest index before advancing).

Working on this exposed problems in JViewport as scrolling through the
list didn't work perfectly, I've fixed what was fixable in
JViewport.scrollRectToVisible but have filed a bug report (PR 24411) for
a subtle problem with Viewports being 1 pixel smaller in width than they
should be.

I also added all the bindings for JList into
BasicLookAndFeel.initComponentDefaults for List.focusInputMap.

Not all the bindings are implemented yet, there is a commented out line
in BasicListUI.ListAction.actionPerformed (the last "else" statement)
that will display the names of unimplemented key bindings.  I don't
think all bindings are actually supposed to do something, like
"selectNextColumn" etc, I'm not sure how this is applicable to Lists but
it's in the JDK's List.focusInputMap.


2005-10-17  Anthony Balkissoon  <address@hidden>

        * javax/swing/JViewport.java:
        (scrollRectToVisible): Return immediately if the View is null.  Check 
        for contentRect being bigger than the port bounds separately in each 
        direction, rather than together.
        * javax/swing/plaf/basic/BasicListUI.java:
        (KeyHandler): Removed this private class that listened directly for 
        key presses.  This is now handled through InputMap-ActionMap pairs.
        (ActionListenerProxy): New class to wrap the Actions for this lists
        ActionMap.
        (ListAction): New class, the actions for keypresses on this list.
        (convertModifiers): New private method converts key press modifiers to 
        the old style (CTRL_MASK instead of CTRL_DOWN_MASK, etc.).
        (installKeyboardActions): Get the InputMap from the UIManager and 
        register new InputMap-ActionMap pairs, then set these as the parents
        of the list's InputMap and ActionMap.
        (selectNextIndex): Avoid NPE by checking if we're already at the last
        index.
        (selectPreviousIndex): Check if we're already at the first index.
        * javax/swing/plaf/basic/BasicLookAndFeel.java:
        (initComponentDefaults): Added bindings for List.focusInputMap.

--Tony

Attachment: JListInputActionPairs.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]