Reputation: 841
Riddle me this: I have a JTabbedPane that has custom JPanels in it. When I try and access those JPanels, all I get back is null. I know that the panels have been added because on the UI I can see the tabs. I can also interact with the panels and switch between tabs. It doesn't matter how I add these JPanels, it always returns null.
Now I could just keep an ArrayList of the JPanels on the side for processing, but I would think that would kinda defeat the purpose of the JTabbedPane keeping any kind of model.
Does anyone know what's going on with this?
Upvotes: 0
Views: 551
Reputation: 54705
You're using the wrong method: getTabComponentAt(int)
will return the Component
used to render the actual tab itself (if you've specified one). You should call getComponentAt(int)
instead. I've done exactly the same thing myself before!
Upvotes: 6