S
steve_marjoribanks
I am having trouble figuring out the best solution to a problem. Seeing
as I am a beginner and this is my first application, I'm not yet quite
in the mindset of a programmer and so I'm struggling to visualize the
best solution so I was hoping you could help me
The overall purpose of the application is to load data from an XML file
and then represent it graphically on one JPanel, and display a JTree
representation of the XML file in another JPanel. All the most
important sections of code appear to work, ie. it can open a file,
validate the XML, display the XML tree and draw the required pictorial
representation, but I am having some trouble working out how to remove
the minor 'display bugs'.
When run, the application opens up a 'main' window (JFrame) which
should have no initial visible content other than the menubar and
toolbar. This has a menu and toolbar etc. from which a File Chooser is
loaded when the user selects 'open'. On opening the XML file it is
validated and then a JTabbedPane with 2 tabs should be displayed
filling all the empty area in the main JFrame. One of these tabs
displays the pictorial representation of the data and the other the
JTree.
What I am having trouble working out is how to sructure my code so that
the JTabbedPane only appears on opening a file and is then disposed of
upon closing the file (ie the file is closed but the application remins
running so another file may be opened).
I considered changing the code to use a JDesktopPane instead of the
main JFrame and then opening up the file in an internal frame (the
ability to open multiple files like this within the same application
was a possible extension to my project) but I read in Sun's Swing
tutorial that this can be a non-trivial task.
I also though, would it be possible just to add the JTabbedPane on
loading the application and just use the setVisible method to make it
visible when a file is opened but then I thought that this would create
problems when closing the file as you can't just remove a component and
then add one again when the application is still running.
Any thoughts from people more experienced than me (thats's most of you,
lol) would be greatly appreciated!
Many thanks,
Steve
as I am a beginner and this is my first application, I'm not yet quite
in the mindset of a programmer and so I'm struggling to visualize the
best solution so I was hoping you could help me
The overall purpose of the application is to load data from an XML file
and then represent it graphically on one JPanel, and display a JTree
representation of the XML file in another JPanel. All the most
important sections of code appear to work, ie. it can open a file,
validate the XML, display the XML tree and draw the required pictorial
representation, but I am having some trouble working out how to remove
the minor 'display bugs'.
When run, the application opens up a 'main' window (JFrame) which
should have no initial visible content other than the menubar and
toolbar. This has a menu and toolbar etc. from which a File Chooser is
loaded when the user selects 'open'. On opening the XML file it is
validated and then a JTabbedPane with 2 tabs should be displayed
filling all the empty area in the main JFrame. One of these tabs
displays the pictorial representation of the data and the other the
JTree.
What I am having trouble working out is how to sructure my code so that
the JTabbedPane only appears on opening a file and is then disposed of
upon closing the file (ie the file is closed but the application remins
running so another file may be opened).
I considered changing the code to use a JDesktopPane instead of the
main JFrame and then opening up the file in an internal frame (the
ability to open multiple files like this within the same application
was a possible extension to my project) but I read in Sun's Swing
tutorial that this can be a non-trivial task.
I also though, would it be possible just to add the JTabbedPane on
loading the application and just use the setVisible method to make it
visible when a file is opened but then I thought that this would create
problems when closing the file as you can't just remove a component and
then add one again when the application is still running.
Any thoughts from people more experienced than me (thats's most of you,
lol) would be greatly appreciated!
Many thanks,
Steve