Double Buffer Issue in JTabbedPane

In Programming by timfanelliLeave a Comment

So I tested my client tools for the first time on a Windows XP platform the other day. The system was a clean install running JDK 1.4.2_03 — and to my horror, my JTabbedPane looked horrendous; here’s how it went down… I have a class that extends JFrame, called MainFrame, and MainFrame’s constructor looks something like this:

public class MainFrame
{
   public MainFrame()
   {
      JPanel panel = new JTabbedPane( ... );
      ...
      this.setContentPane( panel );
   }
}

Now, on the Mac and Linux platforms, there is absolutely no issue with this. Everything works great. However, on the windows platform, everytime the panel had to be redrawn, the tabs would be shifted, skewed, missing, duplicated, and other strange sorts of things. It was very strange indeed.

Simple fix:

public class MainFrame
{
   public MainFrame()
   {
      JPanel tabPanel = new JTabbedPane( ... );
      ...
      JPanel panel = new JPanel( new BorderLayout(), true );
      panel.add( tabPanel );
      this.setContentPane( panel );
   }
}

So it seems that the JDK1.4.2_03 on Windows isn’t double buffering their JTabbedPane. Hopefully this will be resolved soon. Do any of you know where I could submit a bug report to sun? :).

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.