An advantage of extending the JFrame class is you can set t

An advantage of extending the JFrame class is ___________________.

you can set the child class properties within the class constructor

there is no other way to cause an application to close when the user clicks a JFrame’s Close button

c. there is no other way to make a JFrame visible

d. all of the above

Suppose that you create an application in which you instantiate a JFrame named

frame1 and a JLabel named label1. Which of the following statements within the

application adds label1 to frame1?

label1.add(frame1);

frame1.add(label1);

this.add(label1);

two of the above

The arguments required by the Font constructor include all of the following except ___________________ .

typeface

style

mode

point size

A class that controls component positioning in a JFrame is a ___________________.

container

layout manager

formatter

design supervisor

Which of the following is not true of a JTextField?

A user can type text data into it.

Its data can be set in the program instead of by the user.

A program can set its attributes so that a user cannot type in it.

It is a type of Container.

___________________ are popup windows that can help a user understand the purpose of components in an application and that appear when a user hovers the mouse pointer over the component.

Navigation notes

Tool tips

Help icons

Graphic suggestions

Within an event-driven program, a component on which an event is generated is the __________________.

performer

listener

source

handler

A class that will respond to button-press events must use which phrase in its header?

import java.event

extends Action

extends JFrame

implements ActionListener

A JFrame contains a JButton named button1 that should execute an actionPerformed() method when clicked. Which statement is needed in the JFrame class?

addActionListener(this);

addActionListener(button1);

button1.addActionListener(this);

this.addActionListener(button1);

When you use the getSource() method with an ActionEvent object, the result

is ___________________.

an Object

an ActionEvent

a Component

a TextField

A class can implement ___________________.

one listener

two listeners

as many listeners as it needs

any number of listeners as long as they are not conflicting listeners

When you write a method that reacts to JCheckBox changes, you name the

method ___________________.

itemStateChanged()

actionPerformed()

checkBoxChanged()

any legal identifier you choose

If a class contains two components that might each generate a specific event type,

you can determine which component caused the event by using the ___________________

addActionListener()

getSource()

whichOne()

identifyOrigin()

To group several components such as JCheckBoxes so that a user can select only

one at a time, you create a ___________________ .

JCheckBoxGroup

CheckBoxGroup

JButtonGroup

ButtonGroup

Suppose that you have declared a ButtonGroup named threeOptions and added

three JCheckBoxes named box1, box2, and box3 to it. If you code threeOptions.

, then threeOptions.setSelected(box2);, and then

, the selected box is ___________________.

box1

box2

box3

all of the above

Highlight Answers to end of Chapter Review Questions:

If you add fewer than five components to a BorderLayout, ___________________.

any empty component regions disappear

the remaining components expand to fill the available space

both a and b

none of the above

When you resize a Container that uses BorderLayout, ___________________.

the Container and the regions both change in size

the Container changes in size, but the regions retain their original sizes

the Container retains its size, but the regions change or might disappear

nothing happens

When you create a JFrame named myFrame, you can set its layout manager to

BorderLayout with the statement ___________________.

myFrame.setLayout = new BorderLayout();

myFrame.setLayout(new BorderLayout());

setLayout(myFrame = new BorderLayout());

setLayout(BorderLayout(myFrame));

Which of the following is the correct syntax for adding a JButton named b1 to a

Container named con when using CardLayout?

con.add(b1);

con.add(\"b1\");

con.add(\"Options\", b1);

none of the above

You can use the ___________________ class to arrange components in a single row or

column of a container.

FlowLayout

BorderLayout

CardLayout

BoxLayout

When you use ___________________, the components you add fill their region; they do not

retain their default size.

FlowLayout

BorderLayout

FixedLayout

RegionLayout

The statement ___________________ ensures that components are placed from left to right across a JFrame surface until the first row is full, at which point a second row is

started at the frame surface’s left edge.

setLayout(FlowLayout.LEFT);

setLayout(new FlowLayout(LEFT));

setLayout(new FlowLayout(FlowLayout.LEFT));

setLayout(FlowLayout(FlowLayout.LEFT));

The GridBagLayout class allows you to ___________________.

add components to precise locations within the grid

indicate that specific components should span multiple rows or columns

within the grid

both a and b

none of the above

The statement setLayout(new GridLayout(2,7)); establishes a GridLayout with ___________________ horizontal row(s).

zero

one

two

seven

As you add new components to a GridLayout, ___________________.

they are positioned from left to right across each row in sequence

you can specify exact positions by skipping some positions

both of the above

none of the above

A JPanel is a ___________________.

Window

Container

both of the above

none of the above

The ___________________ class allows you to arrange components as if they are stacked like index or playing cards.

GameLayout

CardLayout

BoxLayout

GridBagLayout

AWTEvent is the child class of ___________________.

EventObject

Event

ComponentEvent

ItemEvent

When a user clicks a JPanel or JFrame, the action generates a(n) ___________________.

ActionEvent

MouseEvent

PanelEvent

KeyboardEvent

Event handlers are ___________________.

abstract classes

concrete classes

listeners

methods

The return type of getComponent() is ___________________.

Object

Component

int

void

The KeyEvent method getKeyChar() returns a(n) ___________________ .

int

char

KeyEvent

AWTEvent

The MouseEvent method that allows you to identify double-clicks is ___________________.

getDouble()

isClickDouble()

getDoubleClick()

getClickCount()

You can use the ___________________method to determine the Object in which an ActionEvent originates.

getObject()

getEvent()

getOrigin()

getSource()

Which of the following is true in a standard menu application?

A JMenuItem holds a JMenu.

A JMenuItem holds a JMenuBar.

A JMenuBar holds a JMenu.

A JMenu holds a JMenuBar.

Fill in the blanks :

_________________________ manager arranges components in rows across the width of a Container; when the current row is filled, additional components are placed in new rows

_________________________ manager generates a stack of containers or components, one on top of another

_________________________ manager divides a container surface into a grid

When you use __________________________ manager the components fill the screen in five regions: north, south, east, west, and center

________________________ is a class that controls component positioning

Program 1 :

Design an application for a pizzeria. The user makes pizza order choices from list boxes, and the application displays the price. The user can choose a pizza size of small ($7), medium ($9), large ($11), or extra-large ($14), and one of any number of toppings. There is no additional charge for cheese, but any other topping adds $1 to the base price. Offer at least five different topping choices. Save the file as JPizza.java.

Program Submission Template Fields:

Strategy for coding the program (Provide informal explanation as to how you approached the problem. What were your given information (input) and expected output? What Java libraries did you need to use):

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________

Sample output (Provide screenshots of it running):

Source code (Provide all Java code you have written.):

Program 2 :

Create a JFrame that holds five buttons with the names of five different fonts. Include a sixth button that the user can click to make a font larger or smaller. Display a demonstration JLabel using the font and size that the user selects. Save the file as JFontSelector.java.

Program Submission Template Fields:

Strategy for coding the program (Provide informal explanation as to how you approached the problem. What were your given information (input) and expected output? What Java libraries did you need to use):

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________

____________________________________________________________________________

Sample output (Provide screenshots of it running):

Source code (Provide all Java code you have written.):

Solution

1.

Ans: An advantage of extending the JFrame class is you can set the child class properties within the class constructor

2.

Ans: frame1.add(label1);

3.

Ans:The arguments required by the Font constructor include all of the following except mode

4.

Ans: A class that controls component positioning in a JFrame is a layout manager

5.

Ans:It is a type of Container.

6.

Ans: Within an event-driven program, a component on which an event is generated is the Source

An advantage of extending the JFrame class is ___________________. you can set the child class properties within the class constructor there is no other way to
An advantage of extending the JFrame class is ___________________. you can set the child class properties within the class constructor there is no other way to
An advantage of extending the JFrame class is ___________________. you can set the child class properties within the class constructor there is no other way to
An advantage of extending the JFrame class is ___________________. you can set the child class properties within the class constructor there is no other way to
An advantage of extending the JFrame class is ___________________. you can set the child class properties within the class constructor there is no other way to
An advantage of extending the JFrame class is ___________________. you can set the child class properties within the class constructor there is no other way to
An advantage of extending the JFrame class is ___________________. you can set the child class properties within the class constructor there is no other way to
An advantage of extending the JFrame class is ___________________. you can set the child class properties within the class constructor there is no other way to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site