-->
当前位置:首页 > 题库

单选题:Fill in the code in the underlined location to display the mouse

Luz5年前 (2021-05-10)题库659
Fill in the code in the underlined location to display the mouse point location when the mouse is pressed in the pane. @[B](2)

###### 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);
######}
######}
A. pane.setOnMouseClicked((e) -> System.out.println(e.getX() + ", " + e.getY()));
B. pane.setOnMousePressed(e -> System.out.println(e.getX() + ", " + e.getY()));
C. pane.setOnMouseReleased(e -> {System.out.println(e.getX() + ", " + e.getY())});
D. pane.setOnMouseDragged((e) -> System.out.println(e.getX() + ", " + e.getY()));





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


答案:B