In a JTextPane what are the MVC components?
Also if I wanted to know for a JComponent their MVC parts how can discovery them?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Swing, MVC organization is recursively done.
At first glance, one can consider each JComponent is a view rendering an associated model. In the case of the JTextPane, the associated model is given by the
getStyledDocument()method : the document is updated by the JTextPane, and the control layer is provided by the various Swing listeners, which allow you to interact with both model and view.However, at another level, there is another MVC where the JComponent becomes the model : it’s the LnF. Indeed, in this layer, the JComponent is rendered using a ComponentRenderer, where listeners triggers view repaint from model update. But these configuration are almost of no interest in “basic” Swing code.
Considering MVC counterpart discovery, I’m a little puzzled by this question.
Indeed, as far as I know, if the JComponent knows its associated model, it must have no knowledge of its listeners other than the ability to call their listening methods (defined by their *Listener interface).
Besides, developer.com has an article on the Swing/MVC subject.