public abstract class MathListener
extends java.lang.Object
implements java.util.EventListener
Constructor and Description |
---|
MathListener()
The constructor that is typically called from Mathematica.
|
MathListener(KernelLink ml)
Call this version only when you know for sure what link should be used
for UI-triggered computations.
|
MathListener(java.lang.String[][] handlers)
This form of the constructor lets you skip having
to make a series of setHandler() calls.
|
Modifier and Type | Method and Description |
---|---|
protected Expr |
callMathHandler(java.lang.String meth,
java.lang.Object[] args)
Derived classes call this method from their event handler methods.
|
protected void |
callVoidMathHandler(java.lang.String meth,
java.lang.Object[] args)
Just like callMathHandler(), except it discards the result of the computation.
|
protected java.lang.String |
getHandler(java.lang.String methName)
Allows subclasses to get the name of the Mathematica function assigned to handle the given method.
|
protected KernelLink |
getLink()
Gives the link that will be used by this MathListener for computations.
|
boolean |
setHandler(java.lang.String meth,
java.lang.String func)
Associates the specified Mathematica function with the specified method
from the any of the "listener" interfaces implemented by the class.
|
public MathListener()
public MathListener(KernelLink ml)
ml
- The link to which computations will be sent when events notifications arrive.public MathListener(java.lang.String[][] handlers)
handlers
- An array of {meth, func} pairs associating methods in the derived class
with Mathematica functions.public boolean setHandler(java.lang.String meth, java.lang.String func)
meth
- The method in the "listener" interface (for example, "actionPerformed").func
- The Mathematica function to execute.protected Expr callMathHandler(java.lang.String meth, java.lang.Object[] args)
- the kernel is running DoModal[] - kernel sharing (via ShareKernel[] or ShareFrontEnd[]) is turned on, and the kernel is not busy with some other computation - the kernel executes ServiceJava[] - somewhere on the stack is a call from Mathematica into Java - the program is standalone, not being scripted from a Mathematica session
meth
- the name of the event handler method that is being invoked (e.g., "actionPerformed", "windowClosing", "mousePressed", etc.)args
- the arguments to be passed to the Mathematica handler function. The arguments will be sent individually,
not as a list. To pass primitive types like integers, wrap them in their corresponding wrapper classes
(e.g., new Integer(i)).protected void callVoidMathHandler(java.lang.String meth, java.lang.Object[] args)
meth
- the name of the event handler method that is being invoked (e.g., "actionPerformed", "windowClosing", "mousePressed", etc.)args
- the arguments to be passed to the Mathematica handler function. The arguments will be sent individually,
not as a list. To pass primitive types like integers, wrap them in their corresponding wrapper classes
(e.g., new Integer(i)).callMathHandler(String, Object[])
protected KernelLink getLink()
protected java.lang.String getHandler(java.lang.String methName)
J/Link is Copyright (c) 1999-2020, Wolfram Research, Inc. All rights reserved.