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

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

oliviahorn72

  • Hero Member
  • *****
  • Posts: 579
Analyze the following code.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
// Create a button and place it in the scene
Button btOK = new Button("OK");
btOK.setOnAction(e -> System.out.println("OK 1"));
btOK.setOnAction(e -> System.out.println("OK 2"));
Scene scene = new Scene(btOK, 200, 250);
primaryStage.setTitle("MyJavaFX"); // 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);
}
}

◦ When clicking the button, the program displays OK2.
◦ The program has a compile error, because the setOnAction method is invoked twice.
◦ When clicking the button, the program displays OK1 OK2.
◦ When clicking the button, the program displays OK1.


Related Topics

Need homework help now?

Ask unlimited questions for free

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

scikid

  • Sr. Member
  • ****
  • Posts: 300
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




oliviahorn72

  • Member
  • Posts: 579
Reply 2 on: May 6, 2020
Great answer, keep it coming :)


hollysheppard095

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

 

Did you know?

Today, nearly 8 out of 10 pregnant women living with HIV (about 1.1 million), receive antiretrovirals.

Did you know?

Cutaneous mucormycosis is a rare fungal infection that has been fatal in at least 29% of cases, and in as many as 83% of cases, depending on the patient's health prior to infection. It has occurred often after natural disasters such as tornados, and early treatment is essential.

Did you know?

Side effects from substance abuse include nausea, dehydration, reduced productivitiy, and dependence. Though these effects usually worsen over time, the constant need for the substance often overcomes rational thinking.

Did you know?

Adolescents often feel clumsy during puberty because during this time of development, their hands and feet grow faster than their arms and legs do. The body is therefore out of proportion. One out of five adolescents actually experiences growing pains during this period.

Did you know?

In women, pharmacodynamic differences include increased sensitivity to (and increased effectiveness of) beta-blockers, opioids, selective serotonin reuptake inhibitors, and typical antipsychotics.

For a complete list of videos, visit our video library