ptg7068951
186 HOUR 13:Building a Simple User Interface
Quiz
- Which user component is used as a container to hold other
components?
A. Tu p p e r Wa r e
B. JPanel
C. Choice - Which of the following must be done first within a container?
A. Establish a layout manager.
B. Add components.
C. Doesn’t matter. - What method determines how components are arranged within a container?
A. setLayout()
B. setLayoutManager()
C. setVisible()
Answers
- B.JPanel. You can add components to the panel and then add the
panel to another container such as a frame. - A.Yo u m u s t s p e c i f y t h e l ay o u t m a n a g e r b e f o r e t h e c o m p o n e n t s s o y o u
can add them in the correct way. - A.ThesetLayout()method takes one argument: the layout manager
object that has the job of deciding where components should be dis-
played.
Activities
To i n t e r f a c e f u r t h e r w i t h t h e s u b j e c t o f G U I d e s i g n ,undertake the following
activities:
. Modify the SalutonFrameapplication so that it displays “Saluton
Mondo!” in the frame’s main area instead of the title bar.
. Create a frame that contains another frame and make both of them visi-
ble at the same time.
To s e e J av a p r o g r a m s t h a t i m p l e m e n t t h e s e a c t i v i t i e s ,visit the book’s website
at http://www.java24hours.com.