Ok, this might be tricky to explain but I will do my best. I am creating a dive log record. I am using Tabbed Panes and all that fun stuff to give it a nice GUI. I have several tabs that are going to display/take in different information. For example I have a welcome tab, this one will display the information about the dive log. The diver log will display all the people I have had as dive partners, and dives will be displaying the places I have gone diving. That is just a small idea of what it will be, I have yet to think all the things I will want it to do and display.
What I am having trouble with is I want to display the information from each of the tabs on one page. I will enclose the code below so you can see what I am talking about. What I would like to do is set it up so that I can display information from an object I have saved. I haven't coded in a while and would love any suggestions from the forum for different ways to do that.
I would not implement the Diver class as a component. The Diver should
just contain plain name/address etc. -values and a unique diverID and
just be a plain Object extension.
Then there should be a class, Dive (?) that has info on dive location and
an arraylist of diverIDs, and a diveID
I would not double-store dive info; e.g. not an arrayList of diverIDs in
the Dive class and an arrayList of diveIDs in the Diver class (double house-
keeping). I would choose one of the options.
Then I would make a couple of JPanel extensions, like DiverPanel and
DivePanel that each has a setter method for the class its supposed to
display, - no need to make a bunch of panels, two will do for these.
Then.... I would advice you to have a look at the java.io.Serializable
interface, and implement this in both Dive and Diver. Basically you just
need to implement the readObject & writeObject methods.
If your app then stores the Divers in one arrayList and the Dives in another
you can serialize these arraylists (serialization for ArrayList are implemented
in java). You will have excellent performance without any database, well,
unless you plan to have a national divers log....
Bookmarks