User`s manual

5 Calling Java from MATLAB
5-16
'static final float BOTTOM_ALIGNMENT
% Inherited from java.awt.Component'
'static final float LEFT_ALIGNMENT
% Inherited from java.awt.Component'
'static final float RIGHT_ALIGNMENT
% Inherited from java.awt.Component'
.
.
.
Accessing Private and Public Data
Java API classes provide accessor methods you can use to read from and, where
allowed, to modify private data fields. These are sometimes referred to as get
and set methods, respectively.
Some Java classes have public data fields, which your code can read or modify
directly. To access these fields, use the syntax
object.field.
Examples
The java.awt.Frame class provides an example of access to both private and
public data fields. This class has the read accessor method
getSize, which
returns a
java.awt.Dimension object. The Dimension object has data fields
height and width, which are public and therefore directly accessible. The
following example shows MATLAB commands accessing this data.
frame = java.awt.Frame;
frameDim = getSize(frame);
height = frameDim.height;
frameDim.width = 42;
The programming examples in this chapter also contain calls to data field
accessors. For instance, the sample code for “Example – Finding an Internet
Protocol Address” on page 5-66 uses calls to accessors on a
java.net.InetAddress object.
hostname = address.getHostName;
ipaddress = address.getHostAddress;