Question: Beginning Java with NetBeans: Chapter 22 How to develop a GUI with Swing (part 2) MULTIPLE CHOICE [Answers are in tables delete all but the

Beginning Java with NetBeans: Chapter 22

How to develop a GUI with Swing (part 2)

MULTIPLE CHOICE [Answers are in tables delete all but the correct answers cell]

What method do you use to control whether the user can edit the text thats stored in the component?

a.

setFocusable

c.

setMnemonic

b.

setEditable

d.

setText

Why does a frame continue to be displayed even when the main method terminates?

a.

The frame runs in its own thread.

b.

The frame runs in a separate JVM.

c.

The frame thread blocks the main methods thread.

d.

The garbage collector doesnt dispose of the application object immediately.

What component is often used to display text to identify other components?

a.

text field

c.

label

b.

button

d.

text area

Which of the following statements makes a text field named taxTextField read-only?

a.

taxTextField.setReadOnly(true);

b.

taxTextField.setEditable(true);

c.

setTextField.setEditable(false);

d.

taxTextField.setReadOnly();

What exception is thrown by the following statement if the user enters a string that cant be parsed to a double value?

double d = Double.parseDouble(totalTextField.getText());

a.

ParseException

c.

NumberFormatException

b.

InvalidDataException

d.

ConversionException

Assume that you have a text field named address1. Which of the following statements gets the text from the text field and stores it in a String object named comments?

a.

comments = address1.getText();

b.

comments = address1.getString();

c.

address1.setText(comments);

d.

address1.append(comments);

To allow the user to enter data, you would use a/an

a.

label

c.

text field

b.

dialog box

d.

panel

The GridBagLayout manager

a.

lays out components from left to right.

b.

lays out components so they are all the same size.

c.

lays out components in a grid.

d.

all of the above.

When using the GridBagLayout manager, the ________________ field sets where the component is displayed if the component is smaller than the cell that is its display area.

a.

gridy

c.

gridwidth

b.

gridx

d.

anchor

On most operating systems, a JDialog component is

a.

displayed on top of its parent frame.

b.

has fewer window controls than a JFrame.

c.

does not get its own entry in the taskbar.

d.

all of the above

What field of a GridBagConstraints object specifies the amount of external padding for a component?

a.

ipad

b.

xpad

c.

anchor

d.

insets

What does the following code do?

Dimension dim = new Dimension(100, 20); addressField.setPreferredSize(dim); addressField.setMinimumSize(dim);

a.

It sets the external padding for the component named address.

b.

It sets the internal padding for the component named address.

c.

It prevents the component named address from collapsing to a size of zero.

d.

It prevents the user from resizing the window that contains the component named address field.

In Swing, what class do you inherit to create a custom dialog?

a.

Dialog

c.

JCustomDialog

b.

JDialog

d.

JOptionPane

What method can a custom dialog call to get a reference to its parent component?

a.

getParent()

c.

getOwner()

b.

getWindow()

d.

getFrame()

What class can you use to allow the GUI to remain responsive while a long-running task runs and to be able to update the GUI when that task finishes?

a.

Thread

c.

EventDispatch

b.

SwingWorker

d.

GUIHelper

COMPLETION

To define a label, you use the ________________ component.

To control the layout of components inside a container that uses the GridBagLayout manager, you use the ________________ object.

A/an ________________ dialog prevents the user from interacting with other parts of the application until they have responded to the dialog.

When an application needs a user to enter or edit the data thats stored in a database, most applications use a special type of window known as a/an

To close a dialog, you can call its ________________ method.

Any code that runs in response to a Swing event runs on a special thread called the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!