• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

MVC in Java Text Component

Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you please explain th MVC architecture of java text component, and give the names of some of the classes of each tier.

krishna prasad
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The view is the JTextComponent (which is an abstract class so you'd use a JTextField or a JTextArea or a JPane) this is the view because the JTextComponent is the class that draws what is viewable in the window.

The model is the Document object that the JComponent has a reference to. The Document object is accessible by calling the method: JComponent.getDocument().

The controller is embedded in Swing. The Swing controller calls your listeners as needed once your listeners are registered with the Swing controllers.

The software that I'm working on has a second MVC architecture that I built on top of the Java API.

In this higher-level MVC, I consider the window as a whole as my view.

I consider my Model object as my model. My model object is merely a collection of field models.

I still consider Swing to be the controller, but at the higher-level, I let Swing work automatically once it is set up and only respond to higher-level events that are applicable to the entire window such as "Save".

[ May 19, 2007: Message edited by: Kaydell Leavitt ]
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic