• Home
  • Textbooks
  • Introduction to Programming with Java: A Problem Solving Approach
  • GUI Programming Basics

Introduction to Programming with Java: A Problem Solving Approach

John S. Dean, Raymond H. Dean

Chapter 16

GUI Programming Basics - all with Video Answers

Educators


Chapter Questions

01:03

Problem 1

What is a listener?

Narayan Hari
Narayan Hari
Numerade Educator
00:06

Problem 2

What is an event handler?

Amy Jiang
Amy Jiang
Numerade Educator
01:20

Problem 3

Write a statement that adds functionality to a program's close-window button such that when the closewindow button is clicked, it causes the program to terminate.

Adam Conner
Adam Conner
Numerade Educator
00:50

Problem 4

What is the name of the super class for classes that contain components?

Aditya Sood
Aditya Sood
Numerade Educator
02:10

Problem 5

What package are JButton and many other J-prefixed components defined in?

SS
Sarvesh Somasundaram
Numerade Educator
03:02

Problem 6

Provide an initialization statement that declares a JLabel reference variable named hello and assigns "Hello World" to the reference variable.

Harriet O'Brien
Harriet O'Brien
Numerade Educator
03:06

Problem 7

Provide an initialization statement that instantiates a 10 -character-wide text box object. As part of the initialization, assign the text box object to a reference variable named input.

Foster Wisusik
Foster Wisusik
Numerade Educator
02:10

Problem 8

Write a statement that registers a listener reference variable named responder with a component named component.

SS
Sarvesh Somasundaram
Numerade Educator
00:48

Problem 9

If you want a class to handle an event, what clause must be added to the right side of the class's heading?

Charles Carter
Charles Carter
Numerade Educator
03:07

Problem 10

What is the heading of the one method specified by the ActionListener interface?

SS
Sarvesh Somasundaram
Numerade Educator
01:38

Problem 11

If a class is limited in scope such that it is only needed internally within another class, you should define the class to be an ________.

Aditya Sood
Aditya Sood
Numerade Educator
01:19

Problem 12

If you want to implement an event handler with an anonymous inner class, what argument do you give to the addActionListener method to register the listener?

SS
Sarvesh Somasundaram
Numerade Educator
00:33

Problem 13

In the createContents method of the FactorialButton program in Figure $16.8 \mathrm{a}$, what type of object calls the add methods?

Ernest Castorena
Ernest Castorena
Numerade Educator
01:12

Problem 14

In the FactorialButton program in Figures $16.8 \mathrm{a}$ and $16.8 \mathrm{b}$, what component fires the event that the listener handles?

AG
Ankit Gupta
Numerade Educator
03:07

Problem 15

What package contains the JOptionPane class?

SS
Sarvesh Somasundaram
Numerade Educator
03:42

Problem 16

Write a statement that displays a dialog box in the center of the screen. The dialog box should display "This is only a test." in the message area, "TEST" in the title area, and no icon.

RO
Reynald Oliveria
Numerade Educator
02:10

Problem 17

Suppose you have several components registered with the same listener, and the components and listener are defined within the same class. Within the listener, what ActionEvent method should you call to determine which component fires an event?

SS
Sarvesh Somasundaram
Numerade Educator
02:10

Problem 18

Assume there's a listener that's been registered for several different buttons. Assume the listener uses an actionPerformed method with an ActionEvent parameter named action. Assume that the user clicks one of the registered buttons. Provide a statement that retrieves the text label from the clicked button and assigns the retrieved label to a String variable named buttonLabel.

SS
Sarvesh Somasundaram
Numerade Educator
02:10

Problem 19

Write a statement that sets the text color to blue for a JButton object named button1.

SS
Sarvesh Somasundaram
Numerade Educator
02:55

Problem 20

How do you get a reference to the container that surrounds all of the components in a JFrame object?

SS
Sarvesh Somasundaram
Numerade Educator
00:46

Problem 21

If your program needs the java.awt.event subpackage, you can implicitly import it by importing the java.awt package. (T / F)

Aditya Sood
Aditya Sood
Numerade Educator