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

Author Question: Fill in the code to display the key pressed in the text.import javafx.application.Application;import ... (Read 38 times)

cdr_15

  • Hero Member
  • *****
  • Posts: 546

Question 1

To handle the key pressed event on a pane p, register the handler with p using ________.
◦ p.setOnKeyClicked(handler);
◦ p.setOnKeyPressed(handler);
◦ p.setOnKeyTyped(handler);
◦ p.setOnKeyReleased(handler);

Question 2

Fill in the code to display the key pressed in the text.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
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();
Text text = new Text(20, 20, "Welcome");
pane.getChildren().add(text);
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

text.setFocusTraversable(true);
text.setOnKeyPressed(________);
}

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

◦ e -> text.setText(e.getText())
◦ (e) -> text.setText(e.getText())
◦ () -> text.setText(e.getText())
◦ e -> {text.setText(e.getText());}


Related Topics

Need homework help now?

Ask unlimited questions for free

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

SAUXC

  • Sr. Member
  • ****
  • Posts: 318
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




cdr_15

  • Member
  • Posts: 546
Reply 2 on: May 6, 2020
YES! Correct, THANKS for helping me on my review


hollysheppard095

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

 

Did you know?

Adolescents often feel clumsy during puberty because during this time of development, their hands and feet grow faster than their arms and legs do. The body is therefore out of proportion. One out of five adolescents actually experiences growing pains during this period.

Did you know?

According to the FDA, adverse drug events harmed or killed approximately 1,200,000 people in the United States in the year 2015.

Did you know?

Ether was used widely for surgeries but became less popular because of its flammability and its tendency to cause vomiting. In England, it was quickly replaced by chloroform, but this agent caused many deaths and lost popularity.

Did you know?

About 600,000 particles of skin are shed every hour by each human. If you live to age 70 years, you have shed 105 pounds of dead skin.

Did you know?

The average office desk has 400 times more bacteria on it than a toilet.

For a complete list of videos, visit our video library