17.10. Exercises

You can download the source code for the examples in the book and the solutions to the following exercises from http://www.wrox.com.

  1. Create an application with a square window in the center of the screen that is half the height of the screen by deriving your own window class from JFrame.

  2. Add six buttons to the application in the previous example in a vertical column on the left side of the application window.

  3. Add a menu bar containing the items File, Edit, Window, and Help.

  4. Add a drop-down menu for Edit containing two groups of items of your own choice with a separator between them.

  5. Add another item to the Edit drop-down menu, which itself has a drop-down menu, and provide accelerators for the items in the menu.

  6. Here's an exercise to tickle the brain cells—use a SpringLayout to obtain the button arrangement shown in Figure 17-48 in an application window.

Figure 17.48. Figure 17-48

Get Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.