Created
February 22, 2024 18:38
-
-
Save alexjosesilva/03a87f8c72b49867ea08dd75394c4417 to your computer and use it in GitHub Desktop.
Programação Orientada a Eventos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Button; | |
import javafx.scene.layout.StackPane; | |
import javafx.stage.Stage; | |
public class ProgramaEventos extends Application { | |
@Override | |
public void start(Stage primaryStage) { | |
primaryStage.setTitle("Exemplo de Programação Orientada a Eventos"); | |
// Criando um botão | |
Button button = new Button("Clique Aqui!"); | |
// Definindo o tratador de eventos para o botão | |
button.setOnAction(e -> System.out.println("Botão clicado!")); | |
// Criando o layout da cena | |
StackPane layout = new StackPane(); | |
layout.getChildren().add(button); | |
// Criando a cena | |
Scene scene = new Scene(layout, 300, 250); | |
// Configurando a cena para o palco principal (stage) | |
primaryStage.setScene(scene); | |
// Exibindo o palco principal | |
primaryStage.show(); | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment