Using JButtons for database navigation.
I'm sort of new to java and came across a problem i'm having using some jButtons as database navigation. I'm using 6 buttons Prev Record, Next Record, Enter Query, Execute Query, New Record and Save. I put these buttons on a toolbar which sits on my main jFrame. I have a jPanel on the main also. So I got these buttons to perform perfectly like I want them. I create a new jPanel and place it inside the jPanel on the main screen this new panel has fields which display data from my database. I've created references to the jButtons so they would navigate the records. Like I said works great. Now when I remove the jPanel from the main jPanel using mainPanel.remove(this), and do a repaint on the main screen. I wanted to put a different jpanel inside and navigate some other records this works but it also navigates the records from the panel I removed. So what I see happening is the references to the first panel are still there and garbage collection does not occur right away. Is there an easier way to use jbuttons as multifunction buttons with out creating new buttons for each panel i need to navigate records? Hope I make some sense here.