Swing Display Problem with JTabbedPane

I have an application that used JTabbedPane. Each tab of the tabbed pane is a JPanel, added simply with JTabbedPane.addTab().

The JPanels that serve as tabs range from simple to complex, where the complex JPanels sometimes consist of other JPanels as children, or even JPanels containing JScrollPane()'s containing JPanels containing components etc.

The problem I have is that when the JTabbedPane is initially displayed and the first tab is shown, as I mouse over the tab components from other tabs are displayed. For instance, if I have 2 tabs, tab1 and tab2, and tab1 is initially displayed, then as I mouse over tab1, the components of tab2 can be displayed through tab1. Sometimes the components of non-selected tabs are displayed on the first tab on initial startup even when I don't mouse over. In all instances I'm unable to interact with these components, they just seem to be displayed incorrectly.

The problem is always resolved if I sequentially click on each tab. After doing this, all components are properly laid out and I no longer have the mouse over problem on any tab. The problem re-appears if I programmatically alter the components of tabs not currently being displayed, in which case I need to sequentially click on each tab as described above to resolve the problem.

I've added validate() commands to various parts of the code, but this has not solved the problem.

I realize that this may be a JPanel (or some other) problem that only surfaces when I use a JTabbedPane. I've been through the JTabbed Pane documentation and tutorials and haven't yet found anything to help, which is why I'm here.

Any and all help will be greatly appreciated.

Thanks

[1728 byte] By [kodgehoppera] at [2007-11-26 18:50:44]
# 1
> the components of tab2 can be displayed through tab1. if you run the same program on other pc's, is this odd behaviour the same?if so, post a sample program - 2 tabs, with just enough componentsto produce the problem
Michael_Dunna at 2007-7-9 6:24:47 > top of Java-index,Desktop,Core GUI APIs...
# 2
Which version of java are you using?Which platform?Double check that there are used only Swing components and no AWT components.
dan.ka at 2007-7-9 6:24:47 > top of Java-index,Desktop,Core GUI APIs...
# 3

I'm currently running jdk1.6.0, although the problem occurred while running on jdk1.5.x as well. It should be noted that I'm running this on Linux, using the official JDK from Sun (not gcj or anything of the sort). The application is written in pure Swing, no AWT canvases etc. Thus far, all testing has been performed exclusively on Linux and in all cases the results have been the same (I've tested with at least 2 distributions: Slackware and Mandriva 2007).

As for development tools, the problem occurs both with the new Netbeans 5.5 (and possibly older versions, though I haven't checked) as well as eclipse running the MyEclipseIDE plugin which contains a port of the Netbeans Matisse GUI development framework. While it is possible the IDEs are generating poor code, I doubt that is the problem.

I'll need to set up a Windows box and try it out on that. If the problem still occurs, I'll write a minimal program to replicate the problem and post it here.

Thanks for the replies

kodgehoppera at 2007-7-9 6:24:47 > top of Java-index,Desktop,Core GUI APIs...
# 4
Sorry for the slow response, but I haven't been able to replicate the problem. I'll post back when I do, or when I've solved the problem in my original code.Thanks for the help
kodgehoppera at 2007-7-9 6:24:47 > top of Java-index,Desktop,Core GUI APIs...