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 77 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
Gracias!


JaynaD87

  • Member
  • Posts: 368
Reply 3 on: Yesterday
Thanks for the timely response, appreciate it

 

Did you know?

Warfarin was developed as a consequence of the study of a strange bleeding disorder that suddenly occurred in cattle on the northern prairies of the United States in the early 1900s.

Did you know?

The oldest recorded age was 122. Madame Jeanne Calment was born in France in 1875 and died in 1997. She was a vegetarian and loved olive oil, port wine, and chocolate.

Did you know?

To maintain good kidney function, you should drink at least 3 quarts of water daily. Water dilutes urine and helps prevent concentrations of salts and minerals that can lead to kidney stone formation. Chronic dehydration is a major contributor to the development of kidney stones.

Did you know?

Glaucoma is a leading cause of blindness. As of yet, there is no cure. Everyone is at risk, and there may be no warning signs. It is six to eight times more common in African Americans than in whites. The best and most effective way to detect glaucoma is to receive a dilated eye examination.

Did you know?

Atropine, along with scopolamine and hyoscyamine, is found in the Datura stramonium plant, which gives hallucinogenic effects and is also known as locoweed.

For a complete list of videos, visit our video library