MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manuel d'utilisateur Page 186

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 408
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 185
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;
Vue de la page 185
1 2 ... 181 182 183 184 185 186 187 188 189 190 191 ... 407 408

Commentaires sur ces manuels

Pas de commentaire