This topic contains a solution. Click here to go to the answer

Author Question: Analyze the following code.import javafx.application.Application;import ... (Read 25 times)

rachel9

  • Sr. Member
  • ****
  • Posts: 495
Analyze the following code.

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
Button btOK = new Button("OK");
Button btCancel = new Button("Cancel");

EventHandler handler = new EventHandler() {
public void handle(ActionEvent e) {
System.out.println("The OK button is clicked");
}
};

btOK.setOnAction(handler);
btCancel.setOnAction(handler);

HBox pane = new HBox(5);
pane.getChildren().addAll(btOK, btCancel);

Scene scene = new Scene(pane, 200, 250);
primaryStage.setTitle("Test"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}

/**
* The main method is only needed for the IDE with limited JavaFX
* support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}

◦ The program has a runtime error, because the handler is registered with more than one source.
◦ When clicking the OK button, the program displays The OK button is clicked.
◦ When clicking either button, the program displays The OK button is clicked twice.
◦ When clicking the Cancel button, the program displays The OK button is clicked.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by rachel9 on May 6, 2020

bbburns21

  • Sr. Member
  • ****
  • Posts: 336
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 25% of students answer this correctly




rachel9

  • Member
  • Posts: 495
Reply 2 on: May 6, 2020
Thanks for the timely response, appreciate it


hramirez205

  • Member
  • Posts: 345
Reply 3 on: Yesterday
Gracias!

 

Did you know?

Methicillin-resistant Staphylococcus aureus or MRSA was discovered in 1961 in the United Kingdom. It if often referred to as a superbug. MRSA infections cause more deaths in the United States every year than AIDS.

Methicilli ...
Did you know?

Though Candida and Aspergillus species are the most common fungal pathogens causing invasive fungal disease in the immunocompromised, infections due to previously uncommon hyaline and dematiaceous filamentous fungi are occurring more often today. Rare fungal infections, once accurately diagnosed, may require surgical debridement, immunotherapy, and newer antifungals used singly or in combination with older antifungals, on a case-by-case basis.

Did you know?

Famous people who died from poisoning or drug overdose include, Adolf Hitler, Socrates, Juan Ponce de Leon, Marilyn Monroe, Judy Garland, and John Belushi.

Did you know?

The U.S. Preventive Services Task Force recommends that all women age 65 years of age or older should be screened with bone densitometry.

Did you know?

More than 50% of American adults have oral herpes, which is commonly known as "cold sores" or "fever blisters." The herpes virus can be active on the skin surface without showing any signs or causing any symptoms.

For a complete list of videos, visit our video library