Lillian and others pointed out that sometimes the JTabbedPane didn't
paint correctly the last tab in a run. I found out that there was a
problem in the determination of what is considered the last tab. This
patch fixes the problem.

2006-04-30  Roman Kennke <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicTabbedPaneUI.java
        (lastTabInRun): Fix calculation of the last tab in a run. This
        has caused painting problems sometimes, making the
        last tab painted incorrectly.

/Roman

-- 
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.42
diff -u -1 -0 -r1.42 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java	20 Apr 2006 09:56:30 -0000	1.42
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java	30 Apr 2006 09:26:29 -0000
@@ -2552,24 +2552,37 @@
   /**
    * This method returns the index of the last tab in  a run.
    *
    * @param tabCount The number of tabs.
    * @param run The run to check.
    *
    * @return The last tab in the given run.
    */
   protected int lastTabInRun(int tabCount, int run)
   {
-    if (tabRuns[run] == 0)
-      return tabCount - 1;
+    int lastTab;
+    if (runCount == 1)
+      lastTab = tabCount - 1;
     else
-      return tabRuns[run] - 1;
+      {
+        int nextRun;
+        if (run == runCount - 1)
+          nextRun = 0;
+        else
+          nextRun = run + 1;
+
+        if (tabRuns[nextRun] == 0)
+          lastTab = tabCount - 1;
+        else
+          lastTab = tabRuns[nextRun] - 1;
+      }
+    return lastTab;
   }
 
   /**
    * This method returns the tab run overlay.
    *
    * @param tabPlacement The JTabbedPane's tab placement.
    *
    * @return The tab run overlay.
    */
   protected int getTabRunOverlay(int tabPlacement)

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to