Page 769 - Introduction to Programming with Java: A Problem Solving Approach
P. 769
17.16 More Swing Components 735 It contains picture examples of all the standard Swing components and links to more detailed information.
By perusing that Web page now, you’ll know what’s available.
Menus and Scroll Panes
As a first attempt at learning Swing components on your own, we recommend that you look up the JMenuBar, JMenu, and JMenuItem classes on Sun’s Web site. Those classes allow you to add a menu bar and menus to the top of a window. Also look up the JScrollPane class. It allows you to create a scrollable container. See Figure 17.19. It shows a window with a menu bar and a scroll bar. The menu bar contains two menus—one allows the user to adjust the brightness of the window’s background color and one
Apago PDF Enhancer
After clicking on the Size menu:
⎧ ⎪ ⎨
⎪⎩ }
⎫ ⎬ ⎭
menu bar (JMenuBar component)
scroll bar (from
JScrollPane
container)
menu item (JMenuItem component)
menu (JMenu component)
Figure 17.19 A reader program that uses a menu bar and a scroll bar to adjust the view
⎫ ⎬ ⎭