Summary
The JTable component in Swing is a good example of a class whose developers applied the ADAPTER pattern. A JTable component sets itself up as a client that needs table information as defined by the TableModel interface. This makes it easy for you to write an adapter that feeds the table data from domain objects, such as instances of the Rocket class.
To use JTable, you need to write an object adapter that delegates calls to instances of an existing class. Two aspects of JTable prevent you from using a class adapter. First, you will usually create your table adapter as a subclass of AbstractTableModel, so you can't also subclass your existing class. Second, the JTable class requires a collection of objects, and only an object adapter can ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access