wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes MVC in Java Text Component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "MVC in Java Text Component" Watch "MVC in Java Text Component" New topic
Author

MVC in Java Text Component

krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
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


have a great day,
krishna prasad
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 688

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".

Kaydell
[ May 19, 2007: Message edited by: Kaydell Leavitt ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: MVC in Java Text Component
 
Similar Threads
What is MVC
Best use of JSF
recursive JSF action
BlazeDS vs Spring, and how easy to begin Flex development
jdbc code where i have to write in best programming way