Chapter 24. Pet Store Example

24.1. Pet Store Example

All of the Java code for the Pet Store Example is contained in the file PetStore.java. It defines the following principal classes (in addition to several classes to handle Swing Events):
  • Petstore contains the main() method.
  • PetStoreUI is responsible for creating and displaying the Swing based GUI. It contains several smaller classes, mainly for responding to various GUI events such as mouse button clicks.
  • TableModel holds the table data. It is a JavaBean that extends the Swing class AbstractTableModel.
  • CheckoutCallback allows the GUI to interact with the Rules.
  • Ordershow keeps the items that the customer wishes to buy.
  • Purchase stores details of the order and the products the customer is buying.
  • Product is a JavaBean holding details of the product available for purchase and its price.