com.wolfram.jlink
Class MathKeyListener

java.lang.Object
  extended by com.wolfram.jlink.MathListener
      extended by com.wolfram.jlink.MathKeyListener
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener

public class MathKeyListener
extends MathListener
implements java.awt.event.KeyListener

This class lets you trigger a call into Mathematica on the occurrence of a particular event. Like all the MathXXXListener classes, it is intended to be used primarily from Mathematica, although it can be used from Java code as well.

In response to a KeyEvent, objects of this class send to Mathematica:

     userCode[theKeyEvent, theKeyEvent.getKeyChar(), theKeyEvent.getKeyCode()]
userFunc is specified as a string, either a function name or an expression (like a pure function "foo[##]&"), via the setHandler() method.


Constructor Summary
MathKeyListener()
          The constructor that is called from Mathematica.
MathKeyListener(KernelLink ml)
          You must use this constructor when using this class in a Java program, because you need to specify the KernelLink that will be used.
MathKeyListener(java.lang.String[][] handlers)
          This form of the constructor lets you skip having to make a series of setHandler() calls.
 
Method Summary
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 
Methods inherited from class com.wolfram.jlink.MathListener
callMathHandler, callVoidMathHandler, getHandler, getLink, setHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathKeyListener

public MathKeyListener()
The constructor that is called from Mathematica.


MathKeyListener

public MathKeyListener(KernelLink ml)
You must use this constructor when using this class in a Java program, because you need to specify the KernelLink that will be used.

Parameters:
ml - The link to which computations will be sent when KeyEvents arrive.

MathKeyListener

public MathKeyListener(java.lang.String[][] handlers)
This form of the constructor lets you skip having to make a series of setHandler() calls. Use this constructor from Mathematica code only.

Parameters:
handlers - An array of {meth, func} pairs associating methods in the KeyListener interface with Mathematica functions.
Method Detail

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener


J/Link is Copyright (c) 1999-2008, Wolfram Research, Inc. All rights reserved.