Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Keylistener throws error when Tab is pressed
Keylistener throws error when Tab is pressed [message #461086] Thu, 15 September 2005 18:57 Go to next message
Eclipse UserFriend
Originally posted by: kevin.cs.washington.edu

Some background:
I replaced the SWT text field in the RCP Mail ap with an SWT
ScrolledComposite container and gave it a KeyListener. I think this
error might have something to do with Tab being the key for changing focus.

Here is my code:

(...)

scrolledComposite.addKeyListener(new org.eclipse.swt.events.KeyAdapter(){
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
System.out.println(e);
transmitKeyEvent(e);
}
});

public void transmitKeyEvent(KeyEvent ke){
try{
c.sendKeyEventToTranslator(ke);//the error says ke==null
}catch(Exception e){
e.printStackTrace();
}
}

Here is the error from the printStackTrace():

KeyEvent{ScrolledComposite {} time=3421625 data=null character=' '
keyCode=9 stateMask=0 doit=true}java.lang.NullPointerException
at force.View.transmitKeyEvent(View.java:42)
at force.View$1.keyPressed(View.java:67)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:122)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:880)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:876)
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1190)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3135)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3038 )
at org.eclipse.swt.widgets.Display.windowProc(Display.java:3706 )
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:16 56)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2711)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at force.Application.run(Application.java:24)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
Re: Keylistener throws error when Tab is pressed [message #461088 is a reply to message #461086] Thu, 15 September 2005 19:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kevin.cs.washington.edu

Hmm, I messed something up, now all the keys give this error...

Kevin Chiu wrote:
> Some background:
> I replaced the SWT text field in the RCP Mail ap with an SWT
> ScrolledComposite container and gave it a KeyListener. I think this
> error might have something to do with Tab being the key for changing focus.
>
> Here is my code:
>
> (...)
>
> scrolledComposite.addKeyListener(new org.eclipse.swt.events.KeyAdapter(){
> public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
> System.out.println(e);
> transmitKeyEvent(e);
> }
> });
>
> public void transmitKeyEvent(KeyEvent ke){
> try{
> c.sendKeyEventToTranslator(ke);//the error says ke==null
> }catch(Exception e){
> e.printStackTrace();
> }
> }
>
> Here is the error from the printStackTrace():
>
> KeyEvent{ScrolledComposite {} time=3421625 data=null character=' '
> keyCode=9 stateMask=0 doit=true}java.lang.NullPointerException
> at force.View.transmitKeyEvent(View.java:42)
> at force.View$1.keyPressed(View.java:67)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:122)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:880)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:876)
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1190)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3135)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3038 )
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:3706 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:16 56)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2711)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
> at force.Application.run(Application.java:24)
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
Re: Keylistener throws error when Tab is pressed [message #461090 is a reply to message #461086] Thu, 15 September 2005 19:13 Go to previous message
Eclipse UserFriend
Originally posted by: kevin.cs.washington.edu

Ah, nevermind, it was something completely unrelated. I forgot to make
one of the required methods in my program.

Kevin Chiu wrote:
> Some background:
> I replaced the SWT text field in the RCP Mail ap with an SWT
> ScrolledComposite container and gave it a KeyListener. I think this
> error might have something to do with Tab being the key for changing focus.
>
> Here is my code:
>
> (...)
>
> scrolledComposite.addKeyListener(new org.eclipse.swt.events.KeyAdapter(){
> public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
> System.out.println(e);
> transmitKeyEvent(e);
> }
> });
>
> public void transmitKeyEvent(KeyEvent ke){
> try{
> c.sendKeyEventToTranslator(ke);//the error says ke==null
> }catch(Exception e){
> e.printStackTrace();
> }
> }
>
> Here is the error from the printStackTrace():
>
> KeyEvent{ScrolledComposite {} time=3421625 data=null character=' '
> keyCode=9 stateMask=0 doit=true}java.lang.NullPointerException
> at force.View.transmitKeyEvent(View.java:42)
> at force.View$1.keyPressed(View.java:67)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:122)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:880)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:876)
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1190)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3135)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3038 )
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:3706 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:16 56)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2711)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
> at force.Application.run(Application.java:24)
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
Previous Topic:TreeViewer does not scroll
Next Topic:RCP Mail
Goto Forum:
  


Current Time: Thu Dec 14 00:28:15 GMT 2017

Powered by FUDForum. Page generated in 0.01377 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software