Servis-Rhino 4211B Betriebsanweisung Seite 255

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 298
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 254
javafx.stage.Stage
We can loosely think of the stage object as being a representation of the top level window of the
application. The stage ties to the notion of the native operating system window. When a stage is
shown, it will have properties including size (width and height) as well as others.
A stage doesn't actually appear until and unless it is shown. It can be shown using its "show()"
method.
Some of the more important properties of Stage are:
title – The title of the window
Following on with the metaphor of a play, contained upon a stage is the scene being shown and
JavaFX has the same notion. We can think of the Stage as where the action takes place but it is the
Scene that is the object of attention.
We can set the icon associated with an application using:
stage.getIcons().add(<Image>);
Consider adding multiple images of different sizes. Used 16x16 and 32x32 as a minimum. JavaFX
will correctly choose the appropriate sizes as needed.
For non desktop environments, the stage may be an area in a browser (an applet) or a mobile device
screen area.
javafx.?.Scene
Scenes can be created in a variety of ways but, once done, we can associate the scene with the stage
by calling the stage's "setScene(Scene)" method. Before we can talk further about Scenes, we
must now introduce the idea of a "scene graph". In JavaFX, what the user sees is built out as a set
of "Nodes" where each node represents some UI component. Examples of Nodes include the usual
suspects such as Buttons and Lists and JavaFX provides a rich set of additions. One of the notions
of a Node is that every node has a parent. This means that the nodes form a relationship model (a
tree or graph). This relationship model is the key to JavaFX. We can have simple Nodes such as
Button which are the "leaves" of the tree. They have no children themselves. However other nodes
called "containers" can have children (the parent of these children is the container that contains
them). If we follow the parent/child relationship upwards we will find a single node that is the root
of the tree. This node has no parent. This root node is what is associated with a Scene. When the
Scene is shown, it is the tree represented by the nodes that is actually used to describe what is made
visible to the users.
javafx.scene.image.Image
This class represents an image from a .png or other graphics file. It has a number of sources from
which the data of the image can be read.
For example, to load an image from a file that is in the same directory as a class we can use:
Image image = new Image(MyApplication.class.getResourceAsStream("myImage.png"));
This might be used as the icon image associated with a stage. An Image can also be constructed
from an InputStream. This means that if we can source the image data from elsewhere such as
a database … we can also create an Image.
See also:
JavaFX ImageView
Page 255
Seitenansicht 254
1 2 ... 250 251 252 253 254 255 256 257 258 259 260 ... 297 298

Kommentare zu diesen Handbüchern

Keine Kommentare