TD7

Interface Homme Machine

Séparer logique et graphique

MVC - Modèle Vue Contrôleur

JavaFX - VUE = FXML

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>


<AnchorPane fx:controller="application.ExempleController">
   <children>
      <VBox prefHeight="142.0" prefWidth="185.0">
         <children>
            <TextField fx:id="monChampText"/>
            <Button fx:id="monBeauBouton" text="Click me" onAction="#jaiCliqueSurLeBouton"/>
            <Label fx:id="monLabel" text="Quelle belle interface" textFill="#d01616" />
         </children>
      </VBox>
   </children>
</AnchorPane>

JavaFX - Controller

public class ExempleController {

	@FXML
	private Button monBeauBouton;
	
	@FXML
	private TextField monChampText;
	
	@FXML
	private Label monLabel;
	
	@FXML
	public void jaiCliqueSurLeBouton(ActionEvent event) {
		//System.out.println(monChampText.getText());
		monLabel.setText(monChampText.getText());
	}
}

Complexité

Made with Slides.com