Dynamic Rows in JTable
Ok, I'm trying to do something in a JTable and I'm not sure how to do it. I am writing an app to display some fuel tank level information for some convience stores. I can list the stores and the tank information in the JTable just fine. It looks like this:
Store Tank Fuel Type
123 1 No Lead
123 2 Premium
123 4 Diesel
456 1 No Lead
456 2 Premium
456 4 Diesel
But, what I would like instead is:
And, if you click on a store number, like '123' it would then display:
->Tank 1 No Lead
->Tank 2 Premium
->Tank 4 Diesel
And, if I was to click on 123 again, it would roll back up to how it looked before:
Now, I know how to do this in HTML with CSS. It's pretty easy. But, since this is a regular app, I'm not sure how to do it.
Maybe, I need to not make the whole thing a JTable, and just a JList with the store numbers. Then, when you click on a store number, it would display a JTable with the tank info. That would work, but I don't know if I could make the formatting look good.
Any help or suggestions would be great. Thanks.