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


kilada

  • Member
  • Posts: 311
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

Persons who overdose with cardiac glycosides have a better chance of overall survival if they can survive the first 24 hours after the overdose.

Did you know?

A recent study has found that following a diet rich in berries may slow down the aging process of the brain. This diet apparently helps to keep dopamine levels much higher than are seen in normal individuals who do not eat berries as a regular part of their diet as they enter their later years.

Did you know?

The largest baby ever born weighed more than 23 pounds but died just 11 hours after his birth in 1879. The largest surviving baby was born in October 2009 in Sumatra, Indonesia, and weighed an astounding 19.2 pounds at birth.

Did you know?

Intradermal injections are somewhat difficult to correctly administer because the skin layers are so thin that it is easy to accidentally punch through to the deeper subcutaneous layer.

Did you know?

Eating food that has been cooked with poppy seeds may cause you to fail a drug screening test, because the seeds contain enough opiate alkaloids to register as a positive.

For a complete list of videos, visit our video library