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 34 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
Gracias!


pangili4

  • Member
  • Posts: 346
Reply 3 on: Yesterday
:D TYSM

 

Did you know?

The FDA recognizes 118 routes of administration.

Did you know?

Today, nearly 8 out of 10 pregnant women living with HIV (about 1.1 million), receive antiretrovirals.

Did you know?

When Gabriel Fahrenheit invented the first mercury thermometer, he called "zero degrees" the lowest temperature he was able to attain with a mixture of ice and salt. For the upper point of his scale, he used 96°, which he measured as normal human body temperature (we know it to be 98.6° today because of more accurate thermometers).

Did you know?

Malaria was not eliminated in the United States until 1951. The term eliminated means that no new cases arise in a country for 3 years.

Did you know?

The Food and Drug Administration has approved Risperdal, an adult antipsychotic drug, for the symptomatic treatment of irritability in children and adolescents with autism. The approval is the first for the use of a drug to treat behaviors associated with autism in children. These behaviors are included under the general heading of irritability and include aggression, deliberate self-injury, and temper tantrums.

For a complete list of videos, visit our video library