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 37 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
Great answer, keep it coming :)


hramirez205

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

 

Did you know?

Street names for barbiturates include reds, red devils, yellow jackets, blue heavens, Christmas trees, and rainbows. They are commonly referred to as downers.

Did you know?

The strongest synthetic topical retinoid drug available, tazarotene, is used to treat sun-damaged skin, acne, and psoriasis.

Did you know?

Over time, chronic hepatitis B virus and hepatitis C virus infections can progress to advanced liver disease, liver failure, and hepatocellular carcinoma. Unlike other forms, more than 80% of hepatitis C infections become chronic and lead to liver disease. When combined with hepatitis B, hepatitis C now accounts for 75% percent of all cases of liver disease around the world. Liver failure caused by hepatitis C is now leading cause of liver transplants in the United States.

Did you know?

Approximately 15–25% of recognized pregnancies end in miscarriage. However, many miscarriages often occur before a woman even knows she is pregnant.

Did you know?

Green tea is able to stop the scent of garlic or onion from causing bad breath.

For a complete list of videos, visit our video library