Hello,
I am a little confused by the JTree, JSpinner, their models and their relationship to the applications data model that stores the data it/they display.
When using JTables I make my data model in the manner described below and it is relatively easy to plug that into the JTable.
Do I do the same with a JTree? If so, how?
My data model consists of :
Class : BookManager : Provides methods to manage the contents of an ArrayList that stores Book objects - add, remove, find, get, etc.
Class : Book : Provides methods to manage the contents of an ArrayList that stores Chapter objects - add, remove, find, get, etc.
Class : Chapter : Provides methods to manage the contents of an ArrayList that stores Scene objects - add, remove, find, get, etc.
Class : Scene : Provides getter/setter methods for two
String fields - shortDescription and sceneBody.
I can manipulate and edit the data model using menuitems and display the data model in textual form - using the following menu commands..,
add book
delete book
next book
previous book
add chapter
delete chapter
next chapter
previous chapter
add scene
delete scene
next scene
previous scene
I want to use JMenuItems, a JSpinner and JTree in combination as both view and controller of the data model.
I know how to use JMenuItem's to add/remove Books but I don't know how to display these Book titles in the JSpinner.
I want to use a JSpinner to select the Book to display in the JTree.
I want to use a popup menu on the root node Book to add Chapters to the Book in the JTree.
I want to use a popup menu on Chapter nodes to add Scenes to the selected Chapter or delete the selected Chapter ( and all of its Books ).
I want to use a popup menu on Scene nodes to delete the selected Scene.
I am really confused by the JSpinner and JTree models that seem to sit between the JSpinner, JTree and my data model - I don't understand how I connect my data model to the JSpinner and JTree via their models.
Can anyone give me a little help.
Thanks
[ October 25, 2005: Message edited by: D R Wilkinson ]