Chapter 16: Layout Managers

The exercises here are taken from my forthcoming book The Java Developer's Resource.


  1. What's the difference between a BorderLayout and a FlowLayout?
  2. What's the difference between a GridLayout and a GridBagLayout?


  1. Add a Fast Forward Button to Pragram 16.1.
  2. Add a GridLayout to the PaymentMethod applet of last chapter.
  3. Use a CardLayout to provide a complete pizza ordering system. The first card should ask the user about their pizza, how big it is and what toppings they want. The second card should collect payment information, that is how they wish to pay, their name, and their credit card information (name, card number, and expiration date.) The final card should be for the address and delivery instructions.
  4. Make the calculator applet behave as a calculator, i.e. when you hit the keys 3 + 2 = the screen should show 5, and so on.
  5. Hard: Define a class key which includes both the display as a button and the functionality of the Calculator key. This will require some thought for what the total data structure is which represents the current calculation and how the keys relate to that. This will probably be easier if you do exercise one first.

[ Exercises | Cafe Au Lait | Books | Trade Shows | Links | FAQ | Tutorial | User Groups ]

Copyright 1996 Elliotte Rusty Harold
Last Modified August 20, 1996