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 69 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


epscape

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

 

Did you know?

If you use artificial sweeteners, such as cyclamates, your eyes may be more sensitive to light. Other factors that will make your eyes more sensitive to light include use of antibiotics, oral contraceptives, hypertension medications, diuretics, and antidiabetic medications.

Did you know?

A headache when you wake up in the morning is indicative of sinusitis. Other symptoms of sinusitis can include fever, weakness, tiredness, a cough that may be more severe at night, and a runny nose or nasal congestion.

Did you know?

Patients who have been on total parenteral nutrition for more than a few days may need to have foods gradually reintroduced to give the digestive tract time to start working again.

Did you know?

Alcohol acts as a diuretic. Eight ounces of water is needed to metabolize just 1 ounce of alcohol.

Did you know?

Not getting enough sleep can greatly weaken the immune system. Lack of sleep makes you more likely to catch a cold, or more difficult to fight off an infection.

For a complete list of videos, visit our video library