Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Adapter Design Pattern

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Browsed quiet a few examples on the web but couldn't logically understand the Adapter Design Pattern.

Can somebody give me a smallest & simplest example of Adapter Design Pattern in Java.

Thanks.
Mark
 
MyExamCloud Software Support
Posts: 692
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You have a CustomerJavaBean and you want to display the values in the form of JTable. The model object is not interested to implement TableModel but it is expecting TableModel implementation to display the values. This will be solved by creating an intermediary adapter class actually uses the CustomerJavaBean methods in order implement the TableModel.

public class CustomerJavaBean{
}

public class CustomerJavaBeanAdapter implements
TableModel { ... }
 
Mark Butcher
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks koilraj abraham.....that helped !
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic