109k views
5 votes
Which of the following code correctly registers a handler with a button btOK?a. btOK.setOnAction(e -> System.out.println("Handle the event"));b. btOK.setOnAction((e) -> System.out.println("Handle the event"););c. btOK.setOnAction((ActionEvent e) -> System.out.println("Handle the event"));d. btOK.setOnAction(e -> {System.out.println("Handle the event");});

User Melihovv
by
6.3k points

1 Answer

5 votes

Answer:

The correct answer is C:

btOK.setOnAction((ActionEvent e) -> System.out.println("Handle the event"));

Step-by-step explanation:

The button produces an action once clicked. The setOnAction method indicates what will happen when the button is clicked. Action Event is a type of event that gets processed by EventHandler, which provides the action to be performed by clicking the button (printing out "Handle the event").

User Runner Bean
by
5.7k points