Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Event Listener Exceptions

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 Master Ben   Members   

134
Like
0Likes
Like

Posted 02 September 2013 - 07:16 PM

When I override some Key Listener code with:

    @Override
    public void keyPressed(KeyEvent e) {
        Object source = e;
        System.out.print(e);
        throw new UnsupportedOperationException("Not supported yet.");
    }

I get a crazy list of exceptions that I have no idea how to fix or where it came from. I get the output that I'm looking for, though, so I could ignore it, but I'd rather know what's going on. Any help?

 

 

Some exceptions for pressing the h key, then the v key:

 

 



java.awt.event.KeyEvent[KEY_PRESSED,keyCode=72,keyText=H,keyChar='h',keyLocation=KEY_LOCATION_STANDARD,rawCode=72,primaryLevelUnicode=104,scancode=35,extendedKeyCode=0x48] on frame0Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
 at pong.Pong.keyPressed(Pong.java:47)
 at java.awt.Component.processKeyEvent(Component.java:6463)
 at java.awt.Component.processEvent(Component.java:6282)
 at java.awt.Container.processEvent(Container.java:2229)
 at java.awt.Window.processEvent(Window.java:2022)
 at java.awt.Component.dispatchEventImpl(Component.java:4861)
 at java.awt.Container.dispatchEventImpl(Container.java:2287)
 at java.awt.Window.dispatchEventImpl(Window.java:2719)
 at java.awt.Component.dispatchEvent(Component.java:4687)
 at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)
 at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
 at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
 at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
 at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
 at java.awt.Component.dispatchEventImpl(Component.java:4731)
 at java.awt.Container.dispatchEventImpl(Container.java:2287)
 at java.awt.Window.dispatchEventImpl(Window.java:2719)
 at java.awt.Component.dispatchEvent(Component.java:4687)
 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
 at java.awt.EventQueue.access$200(EventQueue.java:103)
 at java.awt.EventQueue$3.run(EventQueue.java:694)
 at java.awt.EventQueue$3.run(EventQueue.java:692)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
 at java.awt.EventQueue$4.run(EventQueue.java:708)
 at java.awt.EventQueue$4.run(EventQueue.java:706)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
 at pong.Pong.keyTyped(Pong.java:41)
 at java.awt.Component.processKeyEvent(Component.java:6460)
 at java.awt.Component.processEvent(Component.java:6282)
 at java.awt.Container.processEvent(Container.java:2229)
 at java.awt.Window.processEvent(Window.java:2022)
 at java.awt.Component.dispatchEventImpl(Component.java:4861)
 at java.awt.Container.dispatchEventImpl(Container.java:2287)
 at java.awt.Window.dispatchEventImpl(Window.java:2719)
 at java.awt.Component.dispatchEvent(Component.java:4687)
 at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)
 at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
 at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
 at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
 at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
 at java.awt.Component.dispatchEventImpl(Component.java:4731)
 at java.awt.Container.dispatchEventImpl(Container.java:2287)
 at java.awt.Window.dispatchEventImpl(Window.java:2719)
 at java.awt.Component.dispatchEvent(Component.java:4687)
 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
 at java.awt.EventQueue.access$200(EventQueue.java:103)
 at java.awt.EventQueue$3.run(EventQueue.java:694)
 at java.awt.EventQueue$3.run(EventQueue.java:692)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
 at java.awt.EventQueue$4.run(EventQueue.java:708)
 at java.awt.EventQueue$4.run(EventQueue.java:706)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
 at pong.Pong.keyReleased(Pong.java:52)
 at java.awt.Component.processKeyEvent(Component.java:6466)
 at java.awt.Component.processEvent(Component.java:6282)
 at java.awt.Container.processEvent(Container.java:2229)
 at java.awt.Window.processEvent(Window.java:2022)
 at java.awt.Component.dispatchEventImpl(Component.java:4861)
 at java.awt.Container.dispatchEventImpl(Container.java:2287)
 at java.awt.Window.dispatchEventImpl(Window.java:2719)
 at java.awt.Component.dispatchEvent(Component.java:4687)
 at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)
 at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
 at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
 at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
 at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
 at java.awt.Component.dispatchEventImpl(Component.java:4731)
 at java.awt.Container.dispatchEventImpl(Container.java:2287)
 at java.awt.Window.dispatchEventImpl(Window.java:2719)
 at java.awt.Component.dispatchEvent(Component.java:4687)
 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
 at java.awt.EventQueue.access$200(EventQueue.java:103)
 at java.awt.EventQueue$3.run(EventQueue.java:694)
 at java.awt.EventQueue$3.run(EventQueue.java:692)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
 at java.awt.EventQueue$4.run(EventQueue.java:708)
 at java.awt.EventQueue$4.run(EventQueue.java:706)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=86,keyText=V,keyChar='v',keyLocation=KEY_LOCATION_STANDARD,rawCode=86,primaryLevelUnicode=118,scancode=47,extendedKeyCode=0x56] on frame0BUILD SUCCESSFUL (total time: 1 minute 2 seconds)


#2 Serapth   Members   

6671
Like
5Likes
Like

Posted 02 September 2013 - 07:47 PM

*
POPULAR

Ummm... It's your exception, you are the one throwing it.

Remove the throw statement and it will go away.

#3 Master Ben   Members   

134
Like
0Likes
Like

Posted 03 September 2013 - 04:48 PM

Oh... NetBeans put it in there for me when I made the override, and I assumed it showed what it could throw, not TO throw it... Thanks!



#4 Stani R.   Members   

1067
Like
0Likes
Like

Posted 03 September 2013 - 05:06 PM

The declaration of what exceptions a method can throw are part of the method's signature, not part of the method's body. It's also written a bit differently: "throws Exception" vs "throw new Exception()" - the first describes the method, the second creates a new exception object and throws it.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.