Question 1

For each of the following, name the design pattern that the described situation exploits.
  1. Adding a JScrollPane to a JTextArea object and being able to use either as a GUI component


  2. Using a LayoutManager to hide the details of layout from a container object.


  3. Being able to call getPreferredSize on both a JButton and a JPanel.


  4. Implementing a polymorphic method by calling primitive methods.


  5. Being able to successively find tokens within a string without keeping track of a string position.


  6. Automatically updating the view of a table when the table's data changes.


For each of the following, name the design pattern that the described situation exploits.
  1. Adding a JScrollPane to a JTextArea object and being able to use either as a GUI component

    Decorator

  2. Using a LayoutManager to hide the details of layout from a container object.

    Strategy

  3. Being able to call getPreferredSize on both a JButton and a JPanel.

    Composite

  4. Implementing a polymorphic method by calling primitive methods.

    Template Method

  5. Being able to successively find tokens within a string without keeping track of a string position.

    Iterator

  6. Automatically updating the view of a table when the table's data changes.

    Observer