Starting Out With Java: From Control Structures Through Objects, Student Value Edition (7th Edition)
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 12, Problem 11AW

Explanation of Solution

Event handler:

  • The event handler is nothing but an object that responds to the events.
  • A particular method in the event handler is called if an event source is connected to the event handler. The object of the event is passed as the argument to that method.
    • This process is known as event firing.
  • The event handler class should implement the “EventHandler” interface.
    • This interface is in the package “javafx.event”.

Algorithm to create an event handler class

Step 1: Declare a class named “ButtonClickHandler”.

Step 2: Declare a method named “handle”.

Step 3: Set the text for “outputLabel” as “Hello World”

Event handler class:

//Event handler class

class ButtonClickHandler implements EventHandler <ActionEvent>

{

//Overrides handle class

     @Override

     public void handle(ActionEvent event)

     {

//Set the text

     outputLabel.setText("Hello World");

     }

}

Example program:

The below program demonstrates the Event handler class.

//Import required packages

import javafx.application.Application;

import javafx.event.ActionEvent;

import javafx.event.EventHandler;

import javafx.geometry.Pos;

import javafx.geometry.Insets;

import javafx.stage.Stage;

import javafx.scene.Scene;

import javafx.scene.layout.VBox;

import javafx.scene.control.Label;

import javafx.scene.control.Button;

//Declare the main class

public class Example extends Application

{

//Create a label

private Label outputLabel;

//Declare the main method

public static void main(String[] args)

{

// Launch the application...

Blurred answer
Students have asked these similar questions
1. Level the resources (R) for the following network. Show exactly which activity is being moved at each cycle and how many days it is being moved. Show all cycles required to utilize the free float and the back float. B H 3 3 L 2 0-0-0 A C F G K N P Q T 0 3 2 2 1 2-2-2 7R 8R 4R 6R 4R 2R 5R 4R D 1 2R 2 M 000 4R 2 4R 1 2 3 4 B5 B BE B 5 5 7 D 2003 C NO C MBSCM В H 5 2 F 7 7 8 SH2F80 5 Н Н 6 7 7L3G4+ 6H2G4 J 4 4 14 8 L K 00 36 9 10 11 12 13 14 15 P 2 Z+ N N 4 4 Z t 2334 4 Σ + M M 4 +
2. Perform resource allocation for the following project. Resource limits are 6 labors and 2 helpers. Legend: Activity Dur Resources G H 2 3 2L 1H 2L OH A 1 3L 1H + B D F J K 3 4 6 2 4 4L 2H 3L OH 4L 1H 2L 2H 4L 2H C E 2 2 I 1 2L 1H 3L 1H 5L 1H
Need Java method please. Thank you.

Chapter 12 Solutions

Starting Out With Java: From Control Structures Through Objects, Student Value Edition (7th Edition)

Chapter 12.2, Problem 12.11CPChapter 12.2, Problem 12.12CPChapter 12.2, Problem 12.13CPChapter 12.2, Problem 12.14CPChapter 12.3, Problem 12.15CPChapter 12.3, Problem 12.16CPChapter 12.3, Problem 12.17CPChapter 12.3, Problem 12.18CPChapter 12.3, Problem 12.19CPChapter 12.4, Problem 12.20CPChapter 12.4, Problem 12.21CPChapter 12.4, Problem 12.22CPChapter 12.4, Problem 12.23CPChapter 12.4, Problem 12.24CPChapter 12.5, Problem 12.25CPChapter 12.5, Problem 12.26CPChapter 12.5, Problem 12.27CPChapter 12.5, Problem 12.28CPChapter 12.6, Problem 12.29CPChapter 12.6, Problem 12.30CPChapter 12.6, Problem 12.31CPChapter 12.6, Problem 12.32CPChapter 12.7, Problem 12.33CPChapter 12.7, Problem 12.34CPChapter 12.8, Problem 12.35CPChapter 12.9, Problem 12.36CPChapter 12.9, Problem 12.37CPChapter 12, Problem 1MCChapter 12, Problem 2MCChapter 12, Problem 3MCChapter 12, Problem 4MCChapter 12, Problem 5MCChapter 12, Problem 6MCChapter 12, Problem 7MCChapter 12, Problem 8MCChapter 12, Problem 9MCChapter 12, Problem 10MCChapter 12, Problem 11MCChapter 12, Problem 12MCChapter 12, Problem 13MCChapter 12, Problem 14MCChapter 12, Problem 15TFChapter 12, Problem 16TFChapter 12, Problem 17TFChapter 12, Problem 18TFChapter 12, Problem 1FTEChapter 12, Problem 2FTEChapter 12, Problem 3FTEChapter 12, Problem 4FTEChapter 12, Problem 5FTEChapter 12, Problem 1AWChapter 12, Problem 2AWChapter 12, Problem 3AWChapter 12, Problem 4AWChapter 12, Problem 5AWChapter 12, Problem 6AWChapter 12, Problem 7AWChapter 12, Problem 8AWChapter 12, Problem 9AWChapter 12, Problem 10AWChapter 12, Problem 11AWChapter 12, Problem 12AWChapter 12, Problem 13AWChapter 12, Problem 14AWChapter 12, Problem 1SAChapter 12, Problem 2SAChapter 12, Problem 3SAChapter 12, Problem 4SAChapter 12, Problem 5SAChapter 12, Problem 6SAChapter 12, Problem 7SAChapter 12, Problem 8SAChapter 12, Problem 9SAChapter 12, Problem 10SAChapter 12, Problem 11SAChapter 12, Problem 1PCChapter 12, Problem 2PCChapter 12, Problem 3PCChapter 12, Problem 4PCChapter 12, Problem 5PCChapter 12, Problem 6PCChapter 12, Problem 7PCChapter 12, Problem 8PCChapter 12, Problem 9PCChapter 12, Problem 10PC
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Time Complexity Analysis - How To Calculate Running Time | InterviewBit; Author: InterviewBit;https://www.youtube.com/watch?v=--oxG4Q1PA0;License: Standard YouTube License, CC-BY