package buttongui; import static com.sun.deploy.config.JREInfo.clear; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.layout.BorderPane; import javafx.scene.layout.FlowPane; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class ButtonGUI extends Application implements EventHandler { @Override public void start(Stage primaryStage) { btn.setText(\"Find\"); btn.setOnAction(this); btn1.setText(\"Clear\"); btn1.setOnAction(this); btn2.setText(\"Exit\"); btn2.setOnAction(this); FlowPane flow = new FlowPane(); flow.getChildren().addAll(btn,btn1,btn2); BorderPane border = new BorderPane(); border.setCenter(flow); Scene scene = new Scene(border, 300,250); primaryStage.setTitle(\"ButtonGUI\"); primaryStage.setScene(scene); primaryStage.show(); } @Override public void handle(ActionEvent event) { String tx =\"Hello world\"; System.out.println(tx); if(btn2 == event.getSource()){ System.out.println(\"Exit Pressed\"); System.exit(0); } } public static void main(String[] args)throws Exception { launch(args); } } Simple Exit & Clear Events) Add the Exit Event to your ButtonsGUI. Make it so that when the user clicks on the Exit button, the application ends. Add the Clear Event to your ButtonsGUI. Make it so that when the user clicks on the Clear button, the Text on all the Buttons is cleared. please solve the clear button so that when the user clicks on the Clear button, the Text on all the Buttons is cleared. thanks Solution Follow below steps to Add the Exit Event to your Buttons GUI: 1. Right Click on the Exit button and choose Events --> Action --> ActionPerformed. 2. The IDE will automatically add an ActionListener to the Exit button and generate a handler method for handling the listener\'s actionPerformed method. 3. The IDE will open up the Source Code window and scroll to where you implement the action you want the button to do when the button is pressed. 4. Add code for what we want the Exit Button to do. You will have to type System.exit(0); 5. Your final Exit button code should look like this: private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } Follow below steps to Add the Clear Event to your Buttons GUI: In below example the text in two of our jTextFields will clear, it is overwriting the existing Text with a blank. 1. Click on the Design tab at the top of your work area to go back to the Form Design 2. Right Click on the Clear button (jButton1). From the pop-up menu select Events --> Action -- > ActionPerformed. 3. Your final source code will be: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { jTextField1.setText(\"\"); jTextField2.setText(\"\"); } Note: You can add as many jTextField depending upon number of buttons y.