Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
My current project is my first attempt to use JTabbedPanes and I have a problem where the panels I put on a tab sometimes don't render, and by sometimes, I mean, I run the program, no panels, run again right away, no panels, run again, panels appear, run again, no panels. I have determined that the main panel I'm adding to the tab appears every time, but the two sub panels do not. As a test, I added a random JLabel to my main panel, which does appear and since it appears in different places depending on where I add it in relation to the two sub-panels, I believe that my two sub-panels are there, just invisible, even though there's no code to make them setVisible(false). I have tried to put in setVisible(true) just in case to no avail. I have also printed the default contents of various "invisible" JTextFields to the console to confirm that they are being created in my constructor.
My code is lengthy and somewhat messy so I don't really want to clutter up this thread with it. At this point, I don't even know if the problem is with the JTabbedPane, or the Panels, and the fact that it sometimes works perfectly fine and other times doesn't is very confusing. If somebody could suggest some possible causes, I would know which sections of code to post, but at this point I have no idea where the problem might even be. My code for adding element to the panels is very straight-forward GridBagLayout code that I've used for years with no problems.
Thanks