Introduction to Java Programming, Seventh Edition, Y. Daniel Liang
Chapter 34 Containers, Layout Managers, and Borders
Section 33.2 Swing Container Structures
1
Which of the following properties are in JFrame?
A.
contentPane
B.
iconImage
C.
jMenuBar
D.
resizable
E.
title
2
Which of the following properties are in JApplet?
A.
contentPane
B.
iconImage
C.
jMenuBar
D.
resizable
E.
title
3
Which of the following are top-level containers (i.e. cannot be embedded in another container)?
A.
JFrame
B.
JApplet
C.
JPanel
D.
JDialog
Section 33.3 Layout Managers
4
The size of a component in a container is determined by __________
A.
the type of layout manager used by the container.
B.
the layout constraints associated with each component.
C.
the size of the container.
D.
certain properties common to all components (such as preferredSize, minimumSize, maximumSize, alignmentX, and alignmentY).
5
Which of the following properties in java.awt.Component may affect layout?
A.
preferredSize
B.
minimumSize
C.
maximumSize
D.
background
E.
font
6
The preferredSize property is ignored in ______________.
A.
FlowLayout
B.
GridLayout
C.
BorderLayout
D.
Null layout
7
Which of the following properties are in FlowLayout?
A.
hgap
B.
vgap
C.
alignment
D.
layout
E.
visible
8
Which of the following properties are in GridLayout?
A.
hgap
B.
vgap
C.
alignment
D.
layout
E.
visible
9
Which of the following properties are in BorderLayout?
A.
hgap
B.
vgap
C.
alignment
D.
layout
E.
visible
10
Which of the following properties are in CardLayout?
A.
hgap
B.
vgap
C.
alignment
D.
layout
E.
visible
11
Suppose that a container c uses a CardLayout manager p. Which of the following methods are valid?
A.
p.first(c)
B.
p.last(c)
C.
p.next(c)
D.
p.previous(c)
12
Suppose that a container c uses a CardLayout manager p. Which of the following methods are valid?
A.
p.first(c)
B.
p.last(c)
C.
p.next(c)
D.
p.previous(c)
13
_______________ can be shared by a GUI component?
A.
A GUI component
B.
A Color object
C.
A Font object
D.
A layout object
E.
An image icon
14
To use no layout manager in a container c, use _________.
A.
c.setLayout()
B.
c.setLayout(new NullLayout())
C.
c.setLayout(null)
D.
c.setLayout(NullLayout)
15
__________ is a Swing layout manager that arranges components in a row or a column.
A.
FlowLayout
B.
BorderLayout
C.
GridLayout
D.
BoxLayout
E.
CardLayout
16
The Box class uses _____________.
A.
FlowLayout
B.
BorderLayout
C.
GridLayout
D.
BoxLayout
E.
CardLayout
Section 33.4 Creating Custom Layout Managers
17
Every layout manager is an instance of __________.
A.
the LayoutManager interface
B.
the LayoutManager class
C.
the Layout interface
D.
the Layout class
Section 33.5 JScrollPane
18
You can construct a JScrollPane using ____________.
A.
new JScrollPane()
B.
new JScrollPane(Component)
C.
new JScrollPane(Component[])
D.
new JScrollPane(Component, Component)
Section 33.6 JTabbedPane
19
You can construct a JTabbedPane using ____________.
A.
new JTabbedPane()
B.
new JTabbedPane(Component)
C.
new JTabbedPane(Component[])
D.
new JTabbedPane(Component, Component)
20
Which of the following are the valid methods in JTabbedPane?
A.
getTabCount()
B.
getTabPlacement()
C.
getTitleAt(index)
D.
getToolTipTextAt(index)
Section 33.7 JSplitPane
21
You can construct a JSplitPane using ____________.
A.
new JSplitPane()
B.
new JSplitPane(Component)
C.
new JSplitPane(Component[])
D.
new JSplitPane(Component, Component)
Section 33.8 Swing Borders
22
A border object is an instance of _________.
A.
Border
B.
BevelBorder
C.
TitledBorder
D.
LineBorder
E.
EmptyBorder
23
Which of the following methods create a LineBorder?
A.
new LineBorder()
B.
new LineBorder(Color.YELLOW, 3)
C.
new LineBorder(Color.YELLOW, 3, true)
D.
BorderFactory.createLineBorder(Color.YELLOW)
E.
BorderFactory.createLineBorder(Color.YELLOW, 4)
24
Which of the following methods create an EtchedBorder?
A.
new EtchedBorder()
B.
new EtchedBorder(Color.YELLOW, Color.RED)
C.
BorderFactory.createEtchedBorder()
D.
BorderFactory.createEtchedBorder(Color.YELLOW, Color.RED)
25
Which of the following methods create a BevelBorder?
A.
new BevelBorder(BevelBorder.LOWERED)
B.
new BevelBorder(BevelBorder.RAISED)
C.
BorderFactory.createBevelBorder(BevelBorder.LOWERED)
D.
BorderFactory.createBevelBorder(BevelBorder.RAISED)
E.
new BevelBorder()
26
Which of the following methods create a TitledBorder?
A.
new TitledBorder("A title")
B.
new TitledBorder(new BevelBorder(BevelBorder.LOWERED))
C.
BorderFactory.createTitledBorder("A title")
D.
BorderFactory.createTitledBorder(new BevelBorder(BevelBorder.LOWERED), "A title")