User`s manual

Invoking Methods on Java Objects
5-19
Invoking Methods on Java Objects
This section explains how to invoke an object’s methods in MATLAB. It also
covers how to obtain information related to the methods that you’re using and
how MATLAB handles certain types of nonstandard situations.
This section addresses the following topics:
“Using Java and MATLAB Calling Syntax”
“Invoking Static Methods on Java Classes”
“Obtaining Information About Methods”
“Java Methods That Affect MATLAB Commands”
“How MATLAB Handles Undefined Methods”
“How MATLAB Handles Java Exceptions”
Using Java and MATLAB Calling Syntax
To call methods on Java objects, you can use the Java syntax
object.method(arg1,...,argn)
In the following example, frame is the java.awt.Frame object created above,
and
getTitle and setTitle are methods of that object.
frame.setTitle('Sample Frame')
title = frame.getTitle
title =
Sample Frame
Alternatively, you can call Java object (nonstatic) methods with the MATLAB
syntax
method(object, arg1,...,argn)
With MATLAB syntax, the java.awt.Frame example above becomes
setTitle(frame, 'Sample Frame')