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 63 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
:D TYSM


diana chang

  • Member
  • Posts: 288
Reply 3 on: Yesterday
Excellent

 

Did you know?

Coca-Cola originally used coca leaves and caffeine from the African kola nut. It was advertised as a therapeutic agent and "pickerupper." Eventually, its formulation was changed, and the coca leaves were removed because of the effects of regulation on cocaine-related products.

Did you know?

Inotropic therapy does not have a role in the treatment of most heart failure patients. These drugs can make patients feel and function better but usually do not lengthen the predicted length of their lives.

Did you know?

Certain chemicals, after ingestion, can be converted by the body into cyanide. Most of these chemicals have been removed from the market, but some old nail polish remover, solvents, and plastics manufacturing solutions can contain these substances.

Did you know?

As of mid-2016, 18.2 million people were receiving advanced retroviral therapy (ART) worldwide. This represents between 43–50% of the 34–39.8 million people living with HIV.

Did you know?

Critical care patients are twice as likely to receive the wrong medication. Of these errors, 20% are life-threatening, and 42% require additional life-sustaining treatments.

For a complete list of videos, visit our video library