Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: com.apple.laf.AquaKeyBindings.class "VK_RETURN" vs java.awt.KeyEvent "VK_ENTER"

  1. #1
    Junior Member
    Join Date
    Dec 2020
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default com.apple.laf.AquaKeyBindings.class "VK_RETURN" vs java.awt.KeyEvent "VK_ENTER"

    Hi,

    I'm using JDK 15.0.1. The JRE System Library rt.jar has classes throwing a NoSuchFieldException when getting KeyStroke for a list of keys in com.apple.laf.AquaKeyBindings.

    I've been trying to find a solution to prevent the exception from within my code witrhout success. Has anyone encountered this problem? All suggestions are welcome!

    Thank you,
    Don6421



    The debug trace stack looks like the following (top of stack is the current execution):

    Class<KeyEvent>.getField("VK_RETURN") -- See Note 1
    AWTKeyStroke.getVKValue("VK_RETURN")
    AWTKeyStroke.getAWTKeyStroke("RETURN")
    KeyStroke.getKeyStroke("RETURN")
    LookAndFeel.loadKeyBindings(InputMap retMap, Object[] keys) -- See Note 2
    LookAndFeel.makeInputMap(Object[] keys) -- See Note 2
    AquaKeyBindings$LateBoundInputMap.createValue(UIDe faults)
    UIDefaults.getFromHashtable("Tree.inputFocusMap")
    UIDefaults.get("Tree.inputFocusMap", Locale)
    MultiUIDefaults.get("Tree.inputFocusMap", Locale)
    UIManager.get("Tree.inputFocusMap", Locale)
    DefaultLookuyp(TreeTableTree, AquaTreeUI, "Tree.inputFocusMap") -- See Note 3
    AquaTreeUI(BasicTreeUI).getInputMap(int condition)
    AquaTreeUI(BasicTreeUI).installKeyboardActions()
    AquaTreeUI.installKeyboardActions()
    AquaTreeUI(BasicTreeUI).installUI(TreeTableTree)
    TreeTableTree(JComponent).setUI(AquaTreeUI)
    TreeTableTree(JTree).setUI(AquaTreeUI)
    TreeTableTree(JTree).updateUI()
    TreeTableTree.updateUI()
    TreeTableTree(JTree) <init>(TreeModel)
    TreeTableTree(TreeExtended). <init>(TreeModelExtended)
    TreeTable <init>()
    TreeTableModel <init>()
    TreeTable <init>(TableColumnExtended[], ITableCellRenderer[])
    DefaultView.createWorkArea()
    DefaultView.createWorkToolsArea()
    DefaultView.createWorkToolsSupportArea()
    DefaultView <init>(EmptyBorder)
    DefaultView <init>()
    Application.setContentPane()
    Application(AbstractFrame<OWNER>) <init>(Dimension)
    Application(AbstractFrame<OWNER>) <init>(String, Dimension)
    Application(DefaultFrame<OWNER>) <init>(String)
    Application <init>()
    Application.main(String[])



    Note 1: Class.getField(String) tries to get the static field VK_RETURN, but it doesn't exist. VK_ENTER does exist. NoSuchFieldException thrown.

    Note 2: The action list (Object[] keys) is String [
    VK KEY, ACTION
    "meta C", "copy",
    "meta V", "paste",
    "meta X", "cut",
    "COPY", "copy,
    "PASTE", "paste",
    "CUT", "cut",
    "UP", "selectPrevious",
    "KP_UP", "selectPrevious",
    "shift UP", "selectPreviousExtendSelection",
    "shift KP_UP", "selectPreviousExtendSelection",
    "DOWN", "selectNext",
    "KP_DOWN",
    "shift DOWN", "selectNextExtendSelection",
    "shift KP_DOWN", "selectNextExtendSelection",
    "RIGHT", "aquaExpandNode",
    "KP_RIGHT", "aquaExpandNode",
    "LEFT", "aquaCollapseNode",
    "KP_LEFT", "aquaCollapseNode",
    "shift RIGHT", "aquaExpandNode",
    "shift KP_RIGHT", "aquaExpandNode",
    "shift LEFT", "aquaCollapseNode",
    "shift KP_LEFT", "aquaCollapseNode",
    "ctrl Left", "aquaCollapseNode",
    "ctrl KP_LEFT", "aquaCollapseNode",
    "ctrl RIGHT", "aquaExpandNode",
    "ctrl KP_RIGHT", "aquaExpandNode",
    "alt RIGHT", "aquaFullyExpandNode",
    "alt KP_RIGHT". "aquaFullyExpandNode",
    "alt LEFT", "aquaFullyCollapseNode",
    "alt KP_LEFT", "aquaFullyCollapseNode",
    "meta A", "selectAll",
    "RETURN", "startEditing"
    ]

    Note 3: sun.swing.DefaultLookup

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,112
    Thanks
    53
    Thanked 2,618 Times in 2,568 Posts

    Default Re: com.apple.laf.AquaKeyBindings.class "VK_RETURN" vs java.awt.KeyEvent "VK_ENTER"

    Where did this line come from? What file is it in?
    "RETURN", "startEditing"
    It looks like AWTKeyStroke.getAWTKeyStroke adds "VK_" to it and does a search with that new String.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: August 20th, 2019, 07:07 AM
  2. Replies: 6
    Last Post: August 16th, 2014, 01:34 AM
  3. Replies: 1
    Last Post: July 16th, 2014, 04:16 AM
  4. Replies: 2
    Last Post: May 22nd, 2014, 01:17 PM
  5. Replies: 2
    Last Post: June 22nd, 2013, 10:30 AM