Servis-Rhino 4211B Guia do Utilizador Página 262

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 298
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 261
can access this list through the node's "getStyleClass()" method which returns an
ObservableList. We can add or remove class names from this list which will have the same
effect as adding or removing classes to be associated with the node.
To select a node within a scene graph we can use the following:
.className – The name of a class that the node belongs to
#idName – The CSS ID value of the node
A style may be explicit set on a node using the node's "setStyle()" method. Otherwise the
style is taken from the default and next from any loaded style sheet and next from any explicitly set
style.
Stylesheets can be applied to any container. A stylesheet can be loaded in a scene through:
scene.getStylesheets().add(<fileName>);
Some of the more interesting styles:
-fx-text-fill - Text color
See also:
JavaFX CSS Reference Guide
JavaFX Dialogs
Imagine we wish to display a new dialog. First we will create the FXML of the new dialog in a
new file. Next we will create its controller. These are the same steps that we would use to create
any new Scene.
In the application which wishes to show the dialog, we can now call:
Stage dialog = new Stage();
dialog.initStyle(StageStyle.UTILITY);
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.setTitle("Error");
FXMLLoader loader = new FXMLLoader();
Parent root = (Parent)loader.load(getClass().getResource("ErrorDialog.fxml").openStream());
ErrorDialog_Controller edC = (ErrorDialog_Controller)loader.getController();
edC.setMessage(e.getMessage());
Scene scene = new Scene(root);
dialog.setScene(scene);
dialog.show();
From a high level, the story is that we create a new stage and set is style and modality. Next we
give it a title.
Now it is time to load its Scene graph. Once done, we can ask the loader for a handle to its
controller. We assume that the controller exposes a method to set the text on the dialog. Finally,
we can show the dialog.
Within the controller of the dialog, we may wish to provide a "close" button. It will be a button
with the following processing:
@FXML
private Button closeButton;
@FXML
void closeButtonAction(ActionEvent event){
Page 262
Vista de página 261
1 2 ... 257 258 259 260 261 262 263 264 265 266 267 ... 297 298

Comentários a estes Manuais

Sem comentários