Page 1 of 2 12 LastLast
Results 1 to 20 of 30
Like Tree2Likes

Thread: Using KeyListener - get a gazillion errors

  1. #1
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Using KeyListener - get a gazillion errors

    I'm trying to get keyEvents to work. Now, when I launch the program I get 0 errors but when I press a key (any key), I get many, many errors. Not sure why.

    Here's my code:

    Java Code:
    package com.kingsofwar.main;
    
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.util.ArrayList;
    
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    
    @SuppressWarnings("serial")
    public class Main extends JPanel {
    
    	public static int screenResolutionWidth = 1366;
    	public static int screenResolutionHeight = 768;
    
    	public static boolean isPlayer1 = true;
    	public static int maxTileSize = 148; // TODO - Calculate maxTileSize based on game resolution.
    	public ArrayList<Card> cards = new ArrayList<Card>();
    	
    	Field field;
    
    	public Main() {
    		KeyListener listener = new MouseControls();
    		addKeyListener(listener);
    		field = new Field(this);
    
    		for (int i = 0; i < 5; i++){
    			if (AssetLoader.tileIsEmpty[0][i]){
    				Card c = new Card((int) AssetLoader.TILE[0][i].getWidth() / 2, // TODO - Improve.
    						(int) (AssetLoader.TILE[0][i].getHeight() / 2) * i * 2,
    						0, true);
    				cards.add(c);	
    				AssetLoader.tileIsEmpty[0][i] = false;
    			}
    		}
    	}
    	public static void main(String[] args) {
    		CardData.initCardData();
    		AssetLoader.initVariables();
    		
    		JFrame frame = new JFrame("Kings of War");
    		frame.add(new Main());
    		frame.setSize(screenResolutionWidth, screenResolutionHeight);
    		frame.setResizable(false);
    		frame.setLocationRelativeTo(null);
    		frame.setVisible(true);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setFocusable(true);
    		
    	}
    }
    Java Code:
    package com.kingsofwar.main;
    
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    
    public class MouseControls implements KeyListener {
    
    	@Override
    	public void keyTyped(KeyEvent e){
    		
    	}
    	
    	@Override
    	public void keyPressed(KeyEvent e){
    		System.out.println("Key Pressed" + KeyEvent.getKeyText(e.getKeyCode()));
    	}
    	
    	@Override
    	public void keyReleased(KeyEvent e){
    		System.out.println("Key Released" + KeyEvent.getKeyText(e.getKeyCode()));
    	}
    
    
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    I get many, many errors.
    Please copy the full text of the error message and paste it here. It has important info about the error.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,411
    Rep Power
    5

    Default Re: Using KeyListener - get a gazillion errors

    Where is the Card class. AssetLoader? What Field class are you trying to use. Nothing has been imported.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  4. #4
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    Quote Originally Posted by jim829 View Post
    Where is the Card class. AssetLoader? What Field class are you trying to use. Nothing has been imported.

    Regards,
    Jim
    I didn't include that information because that would be a lot of code. Actually, I even shortened the code to just the important information. Everything works perfectly without all the keylistener stuff.

    Here's the error report: (please note the error only occurs when I press a key.)

    2014-05-05 23:00:13.577 java[1200:507] An uncaught exception was raised
    2014-05-05 23:00:13.579 java[1200:507] java.lang.NullPointerException
    2014-05-05 23:00:13.581 java[1200:507] (
    0 CoreFoundation 0x00007fff90e2325c __exceptionPreprocess + 172
    1 libobjc.A.dylib 0x00007fff93e0ce75 objc_exception_throw + 43
    2 CoreFoundation 0x00007fff90e22e09 -[NSException raise] + 9
    3 JavaNativeFoundation 0x000000010e4f0457 JNFCallObjectMethod + 212
    4 liblwawt.dylib 0x000000010ed19903 -[AWTView attributedSubstringForProposedRange:actualRange:] + 78
    5 AppKit 0x00007fff95af275d -[NSTextInputContext handleTSMEvent:] + 3476
    6 AppKit 0x00007fff95af19a5 _NSTSMEventHandler + 205
    7 HIToolbox 0x00007fff94d7f1d4 _ZL23DispatchEventToHandlersP14EventTargetRecP14Op aqueEventRefP14HandlerCallRec + 892
    8 HIToolbox 0x00007fff94d7e787 _ZL30SendEventToEventTargetInternalP14OpaqueEventR efP20OpaqueEventTargetRefP14HandlerCallRec + 385
    9 HIToolbox 0x00007fff94d92880 SendEventToEventTarget + 40
    10 HIToolbox 0x00007fff94dd3d0d SendTSMEvent + 33
    11 HIToolbox 0x00007fff94f815ff SendTextInputEvent + 1028
    12 HIToolbox 0x00007fff94fcc89c -[IMKInputSession _copyUniCharsForRange:intoBuffer:ofLength:] + 268
    13 HIToolbox 0x00007fff94fcc96b -[IMKInputSession _coreAttributesFromRange:whichAttributes:actualRan ge:] + 137
    14 HIToolbox 0x00007fff94fcda5c -[IMKInputSession attributedSubstringFromRange:] + 89
    15 CoreFoundation 0x00007fff90d0ea5c __invoking___ + 140
    16 CoreFoundation 0x00007fff90d0e8c4 -[NSInvocation invoke] + 308
    17 CoreFoundation 0x00007fff90db1516 -[NSInvocation invokeWithTarget:] + 54
    18 CoreFoundation 0x00007fff90d810f4 ___forwarding___ + 452
    19 CoreFoundation 0x00007fff90d80ea8 _CF_forwarding_prep_0 + 120
    20 CoreFoundation 0x00007fff90d0ea5c __invoking___ + 140
    21 CoreFoundation 0x00007fff90d0e8c4 -[NSInvocation invoke] + 308
    22 Foundation 0x00007fff91caed47 -[NSConnection dispatchInvocation:] + 135
    23 Foundation 0x00007fff91caea0d -[NSConnection handleRequest:sequence:] + 1434
    24 Foundation 0x00007fff91c55d50 -[NSConnection handlePortCoder:] + 652
    25 Foundation 0x00007fff91c55688 -[NSConnection dispatchWithComponents:] + 50
    26 Foundation 0x00007fff91c39f38 __NSFireMachPort + 257
    27 CoreFoundation 0x00007fff90d54a74 __CFMachPortPerform + 388
    28 CoreFoundation 0x00007fff90d548d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FU NCTION__ + 41
    29 CoreFoundation 0x00007fff90d5484e __CFRunLoopDoSource1 + 478
    30 CoreFoundation 0x00007fff90d45886 __CFRunLoopRun + 1830
    31 CoreFoundation 0x00007fff90d44f25 CFRunLoopRunSpecific + 309
    32 Foundation 0x00007fff91c5206e -[NSConnection sendInvocation:internal:] + 1965
    33 CoreFoundation 0x00007fff90d810f4 ___forwarding___ + 452
    34 CoreFoundation 0x00007fff90d80ea8 _CF_forwarding_prep_0 + 120
    35 HIToolbox 0x00007fff94fc8b3d -[IMKInputSession handleEvent:] + 946
    36 HIToolbox 0x00007fff94f8c1d8 IMKInputSessionProcessEventRef + 45
    37 HIToolbox 0x00007fff94f8b792 InputMethodInstanceProcessEventRef + 100
    38 HIToolbox 0x00007fff94f80d4f TSMEventToInputMethod + 131
    39 HIToolbox 0x00007fff94dd34a0 TSMKeyEvent + 301
    40 HIToolbox 0x00007fff94dc02b7 TSMProcessRawKeyEvent + 3807
    41 AppKit 0x00007fff95af11f0 -[NSTextInputContext handleEvent:] + 731
    42 AppKit 0x00007fff95ad0abd -[NSView interpretKeyEvents:] + 180
    43 liblwawt.dylib 0x000000010ed18870 -[AWTView keyDown:] + 85
    44 AppKit 0x00007fff95a9d65b -[NSWindow sendEvent:] + 1843
    45 liblwawt.dylib 0x000000010ed1c2e5 -[AWTWindow_Normal sendEvent:] + 86
    46 AppKit 0x00007fff95a3ec42 -[NSApplication sendEvent:] + 3395
    47 libosxapp.dylib 0x000000010edb466f -[NSApplicationAWT sendEvent:] + 179
    48 AppKit 0x00007fff9588eb89 -[NSApplication run] + 646
    49 libosxapp.dylib 0x000000010edb4557 +[NSApplicationAWT runAWTLoopWithApp:] + 156
    50 liblwawt.dylib 0x000000010ed0cb99 -[AWTStarter starter:] + 873
    51 Foundation 0x00007fff91c3313e __NSThreadPerformPerform + 229
    52 CoreFoundation 0x00007fff90d54661 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FU NCTION__ + 17
    53 CoreFoundation 0x00007fff90d45d12 __CFRunLoopDoSources0 + 242
    54 CoreFoundation 0x00007fff90d4549f __CFRunLoopRun + 831
    55 CoreFoundation 0x00007fff90d44f25 CFRunLoopRunSpecific + 309
    56 java 0x00000001037a63b0 CreateExecutionEnvironment + 871
    57 java 0x00000001037a0b5c JLI_Launch + 1952
    58 java 0x00000001037a670d main + 101
    59 java 0x00000001037a03b4 start + 52
    )
    2014-05-05 23:00:14.137 java[1200:507] An uncaught exception was raised
    2014-05-05 23:00:14.138 java[1200:507] java.lang.NullPointerException
    2014-05-05 23:00:14.140 java[1200:507] (
    0 CoreFoundation 0x00007fff90e2325c __exceptionPreprocess + 172
    1 libobjc.A.dylib 0x00007fff93e0ce75 objc_exception_throw + 43
    2 CoreFoundation 0x00007fff90e22e09 -[NSException raise] + 9
    3 JavaNativeFoundation 0x000000010e4f0457 JNFCallObjectMethod + 212
    4 liblwawt.dylib 0x000000010ed19903 -[AWTView attributedSubstringForProposedRange:actualRange:] + 78
    5 AppKit 0x00007fff95af275d -[NSTextInputContext handleTSMEvent:] + 3476
    6 AppKit 0x00007fff95af19a5 _NSTSMEventHandler + 205
    7 HIToolbox 0x00007fff94d7f1d4 _ZL23DispatchEventToHandlersP14EventTargetRecP14Op aqueEventRefP14HandlerCallRec + 892
    8 HIToolbox 0x00007fff94d7e787 _ZL30SendEventToEventTargetInternalP14OpaqueEventR efP20OpaqueEventTargetRefP14HandlerCallRec + 385
    9 HIToolbox 0x00007fff94d92880 SendEventToEventTarget + 40
    10 HIToolbox 0x00007fff94dd3d0d SendTSMEvent + 33
    11 HIToolbox 0x00007fff94f815ff SendTextInputEvent + 1028
    12 HIToolbox 0x00007fff94fcc89c -[IMKInputSession _copyUniCharsForRange:intoBuffer:ofLength:] + 268
    13 HIToolbox 0x00007fff94fcc96b -[IMKInputSession _coreAttributesFromRange:whichAttributes:actualRan ge:] + 137
    14 HIToolbox 0x00007fff94fcda5c -[IMKInputSession attributedSubstringFromRange:] + 89
    15 CoreFoundation 0x00007fff90d0ea5c __invoking___ + 140
    16 CoreFoundation 0x00007fff90d0e8c4 -[NSInvocation invoke] + 308
    17 CoreFoundation 0x00007fff90db1516 -[NSInvocation invokeWithTarget:] + 54
    18 CoreFoundation 0x00007fff90d810f4 ___forwarding___ + 452
    19 CoreFoundation 0x00007fff90d80ea8 _CF_forwarding_prep_0 + 120
    20 CoreFoundation 0x00007fff90d0ea5c __invoking___ + 140
    21 CoreFoundation 0x00007fff90d0e8c4 -[NSInvocation invoke] + 308
    22 Foundation 0x00007fff91caed47 -[NSConnection dispatchInvocation:] + 135
    23 Foundation 0x00007fff91caea0d -[NSConnection handleRequest:sequence:] + 1434
    24 Foundation 0x00007fff91c55d50 -[NSConnection handlePortCoder:] + 652
    25 Foundation 0x00007fff91c55688 -[NSConnection dispatchWithComponents:] + 50
    26 Foundation 0x00007fff91c39f38 __NSFireMachPort + 257
    27 CoreFoundation 0x00007fff90d54a74 __CFMachPortPerform + 388
    28 CoreFoundation 0x00007fff90d548d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FU NCTION__ + 41
    29 CoreFoundation 0x00007fff90d5484e __CFRunLoopDoSource1 + 478
    30 CoreFoundation 0x00007fff90d45886 __CFRunLoopRun + 1830
    31 CoreFoundation 0x00007fff90d44f25 CFRunLoopRunSpecific + 309
    32 Foundation 0x00007fff91c5206e -[NSConnection sendInvocation:internal:] + 1965
    33 CoreFoundation 0x00007fff90d810f4 ___forwarding___ + 452
    34 CoreFoundation 0x00007fff90d80ea8 _CF_forwarding_prep_0 + 120
    35 HIToolbox 0x00007fff94fc8b3d -[IMKInputSession handleEvent:] + 946
    36 HIToolbox 0x00007fff94f8c1d8 IMKInputSessionProcessEventRef + 45
    37 HIToolbox 0x00007fff94f8b792 InputMethodInstanceProcessEventRef + 100
    38 HIToolbox 0x00007fff94f80d4f TSMEventToInputMethod + 131
    39 HIToolbox 0x00007fff94dd34a0 TSMKeyEvent + 301
    40 HIToolbox 0x00007fff94dc02b7 TSMProcessRawKeyEvent + 3807
    41 AppKit 0x00007fff95af11f0 -[NSTextInputContext handleEvent:] + 731
    42 AppKit 0x00007fff95ad0abd -[NSView interpretKeyEvents:] + 180
    43 liblwawt.dylib 0x000000010ed18870 -[AWTView keyDown:] + 85
    44 AppKit 0x00007fff95a9d65b -[NSWindow sendEvent:] + 1843
    45 liblwawt.dylib 0x000000010ed1c2e5 -[AWTWindow_Normal sendEvent:] + 86
    46 AppKit 0x00007fff95a3ec42 -[NSApplication sendEvent:] + 3395
    47 libosxapp.dylib 0x000000010edb466f -[NSApplicationAWT sendEvent:] + 179
    48 AppKit 0x00007fff9588eb89 -[NSApplication run] + 646
    49 libosxapp.dylib 0x000000010edb4557 +[NSApplicationAWT runAWTLoopWithApp:] + 156
    50 liblwawt.dylib 0x000000010ed0cb99 -[AWTStarter starter:] + 873
    51 Foundation 0x00007fff91c3313e __NSThreadPerformPerform + 229
    52 CoreFoundation 0x00007fff90d54661 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FU NCTION__ + 17
    53 CoreFoundation 0x00007fff90d45d12 __CFRunLoopDoSources0 + 242
    54 CoreFoundation 0x00007fff90d4549f __CFRunLoopRun + 831
    55 CoreFoundation 0x00007fff90d44f25 CFRunLoopRunSpecific + 309
    56 java 0x00000001037a63b0 CreateExecutionEnvironment + 871
    57 java 0x00000001037a0b5c JLI_Launch + 1952
    58 java 0x00000001037a670d main + 101
    59 java 0x00000001037a03b4 start + 52
    )

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    What program are you executing? What OS are you using?
    I've never seen a stack trace like in post#4
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    I'm using Eclipse for Android and I have Mac OSX 10.9. It's also my first time seeing this error. Is there nothing wrong at all with my 2 classes I posted above? :(

  7. #7
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,411
    Rep Power
    5

    Default Re: Using KeyListener - get a gazillion errors

    If your program is too complicated to post then please provide a Short, Self Contained, Correct Example that demonstrates the problem. Make certain the submitted example can be compiled without errors.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  8. #8
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    I've shorted the code like the instructions said. This code still gives me the same error.

    Java Code:
    import java.awt.event.KeyListener;
    
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    
    public class Main extends JPanel {
    
    	public Main() {
    		KeyListener listener = new MouseControls();
    		addKeyListener(listener);
    	}
    	
    	public static void main(String[] args) {
    		
    		JFrame frame = new JFrame("Kings of War");
    		frame.add(new Main());
    		frame.setSize(500, 500);
    		frame.setResizable(false);
    		frame.setLocationRelativeTo(null);
    		frame.setVisible(true);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setFocusable(true);
    	}
    }
    Java Code:
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    
    
    public class MouseControls implements KeyListener {
    
    	@Override
    	public void keyTyped(KeyEvent e) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	@Override
    	public void keyPressed(KeyEvent e){
    		System.out.println("Key Pressed" + KeyEvent.getKeyText(e.getKeyCode()));
    	}
    	
    	@Override
    	public void keyReleased(KeyEvent e){
    		System.out.println("Key Released" + KeyEvent.getKeyText(e.getKeyCode()));
    	}
    }

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    What happens when this code is compiled and executed?

    Nothing happens when I compile and execute it.
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    I get the errors I posted above. :(

    Also, you said "nothing happens", like not even the key pressed is printed to the console?

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    Nothing happens if I press any key or do anything else. The window just sits there.
    If you don't understand my response, don't ignore it, ask a question.

  12. #12
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,411
    Rep Power
    5

    Default Re: Using KeyListener - get a gazillion errors

    In the last example, don't set focusable true for Frame. Just do a setFocusable(true) in the Main constructor. Then your key listener works fine.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  13. #13
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    806
    Rep Power
    6

    Default Re: Using KeyListener - get a gazillion errors

    In ur main method u add this.KeyListener should be activated on frame first.
    frame.addKeyListener( new MouseControls());
    Last edited by RamyaSivakanth; 05-05-2014 at 06:36 PM.
    Ramya:cool:

  14. #14
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,411
    Rep Power
    5

    Default Re: Using KeyListener - get a gazillion errors

    Quote Originally Posted by RamyaSivakanth View Post
    In ur main method u add this.KeyListener should be activated on frame first.
    frame.addKeyListener( new MouseControls());

    The OP already added the listener to the JPanel. All that is needed is to set focusable for the panel. And he can't use this in the main method. You are not allowed to use "this" keyword in a static context.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  15. #15
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    806
    Rep Power
    6

    Default Re: Using KeyListener - get a gazillion errors

    typo error..

    frame.addKeyListener( new MouseControls()); solves the problem
    Ramya:cool:

  16. #16
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    Quote Originally Posted by jim829 View Post
    In the last example, don't set focusable true for Frame. Just do a setFocusable(true) in the Main constructor. Then your key listener works fine.

    Regards,
    Jim
    Jim's suggestion fixed the problem. The key listener works fine, however, I still get an error log. Not sure if it's something to worry about or not.

    Ramya: Unfortunately, adding that line doesn't seem to change anything. :(

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    I still get an error log.
    Post it.
    If you don't understand my response, don't ignore it, ask a question.

  18. #18
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    Error log:

    2014-05-08 10:09:05.594 java[2420:507] An uncaught exception was raised
    2014-05-08 10:09:05.596 java[2420:507] java.lang.NullPointerException
    2014-05-08 10:09:05.598 java[2420:507] (
    0 CoreFoundation 0x00007fff90e2325c __exceptionPreprocess + 172
    1 libobjc.A.dylib 0x00007fff93e0ce75 objc_exception_throw + 43
    2 CoreFoundation 0x00007fff90e22e09 -[NSException raise] + 9
    3 JavaNativeFoundation 0x000000019b99f457 JNFCallObjectMethod + 212
    4 liblwawt.dylib 0x000000019c1d5903 -[AWTView attributedSubstringForProposedRange:actualRange:] + 78
    5 AppKit 0x00007fff95af275d -[NSTextInputContext handleTSMEvent:] + 3476
    6 AppKit 0x00007fff95af19a5 _NSTSMEventHandler + 205
    7 HIToolbox 0x00007fff94d7f1d4 _ZL23DispatchEventToHandlersP14EventTargetRecP14Op aqueEventRefP14HandlerCallRec + 892
    8 HIToolbox 0x00007fff94d7e787 _ZL30SendEventToEventTargetInternalP14OpaqueEventR efP20OpaqueEventTargetRefP14HandlerCallRec + 385
    9 HIToolbox 0x00007fff94d92880 SendEventToEventTarget + 40
    10 HIToolbox 0x00007fff94dd3d0d SendTSMEvent + 33
    11 HIToolbox 0x00007fff94f815ff SendTextInputEvent + 1028
    12 HIToolbox 0x00007fff94fcc89c -[IMKInputSession _copyUniCharsForRange:intoBuffer:ofLength:] + 268
    13 HIToolbox 0x00007fff94fcc96b -[IMKInputSession _coreAttributesFromRange:whichAttributes:actualRan ge:] + 137
    14 HIToolbox 0x00007fff94fcda5c -[IMKInputSession attributedSubstringFromRange:] + 89
    15 CoreFoundation 0x00007fff90d0ea5c __invoking___ + 140
    16 CoreFoundation 0x00007fff90d0e8c4 -[NSInvocation invoke] + 308
    17 CoreFoundation 0x00007fff90db1516 -[NSInvocation invokeWithTarget:] + 54
    18 CoreFoundation 0x00007fff90d810f4 ___forwarding___ + 452
    19 CoreFoundation 0x00007fff90d80ea8 _CF_forwarding_prep_0 + 120
    20 CoreFoundation 0x00007fff90d0ea5c __invoking___ + 140
    21 CoreFoundation 0x00007fff90d0e8c4 -[NSInvocation invoke] + 308
    22 Foundation 0x00007fff91caed47 -[NSConnection dispatchInvocation:] + 135
    23 Foundation 0x00007fff91caea0d -[NSConnection handleRequest:sequence:] + 1434
    24 Foundation 0x00007fff91c55d50 -[NSConnection handlePortCoder:] + 652
    25 Foundation 0x00007fff91c55688 -[NSConnection dispatchWithComponents:] + 50
    26 Foundation 0x00007fff91c39f38 __NSFireMachPort + 257
    27 CoreFoundation 0x00007fff90d54a74 __CFMachPortPerform + 388
    28 CoreFoundation 0x00007fff90d548d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FU NCTION__ + 41
    29 CoreFoundation 0x00007fff90d5484e __CFRunLoopDoSource1 + 478
    30 CoreFoundation 0x00007fff90d45886 __CFRunLoopRun + 1830
    31 CoreFoundation 0x00007fff90d44f25 CFRunLoopRunSpecific + 309
    32 Foundation 0x00007fff91c5206e -[NSConnection sendInvocation:internal:] + 1965
    33 CoreFoundation 0x00007fff90d810f4 ___forwarding___ + 452
    34 CoreFoundation 0x00007fff90d80ea8 _CF_forwarding_prep_0 + 120
    35 HIToolbox 0x00007fff94fc8b3d -[IMKInputSession handleEvent:] + 946
    36 HIToolbox 0x00007fff94f8c1d8 IMKInputSessionProcessEventRef + 45
    37 HIToolbox 0x00007fff94f8b792 InputMethodInstanceProcessEventRef + 100
    38 HIToolbox 0x00007fff94f80d4f TSMEventToInputMethod + 131
    39 HIToolbox 0x00007fff94dd34a0 TSMKeyEvent + 301
    40 HIToolbox 0x00007fff94dc02b7 TSMProcessRawKeyEvent + 3807
    41 AppKit 0x00007fff95af11f0 -[NSTextInputContext handleEvent:] + 731
    42 AppKit 0x00007fff95ad0abd -[NSView interpretKeyEvents:] + 180
    43 liblwawt.dylib 0x000000019c1d4870 -[AWTView keyDown:] + 85
    44 AppKit 0x00007fff95a9d65b -[NSWindow sendEvent:] + 1843
    45 liblwawt.dylib 0x000000019c1d82e5 -[AWTWindow_Normal sendEvent:] + 86
    46 AppKit 0x00007fff95a3ec42 -[NSApplication sendEvent:] + 3395
    47 libosxapp.dylib 0x000000019c27066f -[NSApplicationAWT sendEvent:] + 179
    48 AppKit 0x00007fff9588eb89 -[NSApplication run] + 646
    49 libosxapp.dylib 0x000000019c270557 +[NSApplicationAWT runAWTLoopWithApp:] + 156
    50 liblwawt.dylib 0x000000019c1c8b99 -[AWTStarter starter:] + 873
    51 Foundation 0x00007fff91c3313e __NSThreadPerformPerform + 229
    52 CoreFoundation 0x00007fff90d54661 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FU NCTION__ + 17
    53 CoreFoundation 0x00007fff90d45d12 __CFRunLoopDoSources0 + 242
    54 CoreFoundation 0x00007fff90d4549f __CFRunLoopRun + 831
    55 CoreFoundation 0x00007fff90d44f25 CFRunLoopRunSpecific + 309
    56 java 0x000000010b9e23b0 CreateExecutionEnvironment + 871
    57 java 0x000000010b9dcb5c JLI_Launch + 1952
    58 java 0x000000010b9e270d main + 101
    59 java 0x000000010b9dc3b4 start + 52
    )
    Key PressedB
    Key ReleasedB

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    java.lang.NullPointerException
    There was a null value where there should not have been one. I'm not familiar with that stack trace to find where the error happened.
    If you don't understand my response, don't ignore it, ask a question.

  20. #20
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    Yea but it happens in the example code I posted too and I don't see anything that's null. :(

Page 1 of 2 12 LastLast

Similar Threads

  1. KeyListener?
    By MW130 in forum New To Java
    Replies: 22
    Last Post: 01-13-2014, 02:28 PM
  2. KeyListener
    By Nh bcu in forum New To Java
    Replies: 2
    Last Post: 10-15-2013, 10:07 AM
  3. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  4. Replies: 3
    Last Post: 03-08-2009, 01:51 AM
  5. KeyListener Example
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 07-11-2008, 04:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •