posted 10 years ago
I have a GUI with a row of buttons across the top. Clicking one of those buttons will display a column of buttons down the left hand side. Clicking one of the column buttons will display a row of buttons across the bottom of the screen. Clicking on each button will also show a grid of data in a JTable displayed in the middle of the screen. The purpose is each new set of buttons will allow the user to drill down to finer detail about the data being displayed. The data comes from a SQL Server database. What I want to do, is to hold all of the buttons in some sort of container so I never have to go to the database to get new buttons. The first buttons along the top, Level1, each have their own specific set of buttons that will show up on the left hand side in a column, Level 2. So button 1 will show different buttons in the column then button 2. Each button in the Level 2 column also has a specific set of buttons to show along the bottom, Level 3, so that the top button will show different buttons along the bottom then the next button down. I had thought of a 3 dimensional HashMap, if there is such a thing. The top map would have a button ID as the key, and the value would be another HashMap containing a button ID as the key and another HashMap as the value. The final map would have a button ID and the name to be displayed as the value. I'm not sure this is the best approach. I want to tie them all together, so that each Level 1 button and it's respective Level 2's with their Level 3's are easily accessible. A tree comes to mind but I can't figure out the best solution. Has anyone ever done anything like this?
Currently, I go to the database to get the Level 1 buttons. When one is clicked, I go to the database to get the Level 2 buttons that are specific to the Level 1 button that was clicked. When a Level 2 button is clicked, I go to the database to get all of the Level 3 buttons that are specific to the Level 2 button clicked. I would like to avoid all this back and forth to the database.
Thanks,