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

Author Question: Fill in the code in the underlined location to display the mouse point location when the mouse is ... (Read 61 times)

mpobi80

  • Hero Member
  • *****
  • Posts: 519

Question 1

To handle the mouse click event on a pane p, register the handler with p using ________.
◦ p.setOnMouseDragged(handler);
◦ p.setOnMousePressed(handler);
◦ p.setOnMouseClicked(handler);
◦ p.setOnMouseReleased(handler);

Question 2

Fill in the code in the underlined location to display the mouse point location when the mouse is pressed in the pane.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class Test extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
Pane pane = new Pane();
________

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);
}
}

◦ pane.setOnMouseClicked((e) -> System.out.println(e.getX() + ", " + e.getY()));
◦ pane.setOnMousePressed(e -> System.out.println(e.getX() + ", " + e.getY()));
◦ pane.setOnMouseReleased(e -> {System.out.println(e.getX() + ", " + e.getY())});
◦ pane.setOnMouseDragged((e) -> System.out.println(e.getX() + ", " + e.getY()));


Related Topics

Need homework help now?

Ask unlimited questions for free

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

nmyers

  • 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 49% of students answer this correctly




mpobi80

  • Member
  • Posts: 519
Reply 2 on: May 6, 2020
Excellent


tuate

  • Member
  • Posts: 332
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

Certain topical medications such as clotrimazole and betamethasone are not approved for use in children younger than 12 years of age. They must be used very cautiously, as directed by a doctor, to treat any child. Children have a much greater response to topical steroid medications.

Did you know?

Opium has influenced much of the world's most popular literature. The following authors were all opium users, of varying degrees: Lewis Carroll, Charles, Dickens, Arthur Conan Doyle, and Oscar Wilde.

Did you know?

The toxic levels for lithium carbonate are close to the therapeutic levels. Signs of toxicity include fine hand tremor, polyuria, mild thirst, nausea, general discomfort, diarrhea, vomiting, drowsiness, muscular weakness, lack of coordination, ataxia, giddiness, tinnitus, and blurred vision.

Did you know?

Pregnant women usually experience a heightened sense of smell beginning late in the first trimester. Some experts call this the body's way of protecting a pregnant woman from foods that are unsafe for the fetus.

Did you know?

The U.S. Pharmacopeia Medication Errors Reporting Program states that approximately 50% of all medication errors involve insulin.

For a complete list of videos, visit our video library