Hi,
I forgot to add an important revalidate() call when a new tab is selected and
the tabbed pane is in WRAP_TAB_LAYOUT mode - something which is not needed when
it is in SCROLL_TAB_LAYOUT mode.

I provided a proper code path for both modes and implemented another missing
feature: Interception of a click on a disabled tab.

Finally a part of the if-else cascade was wrongly indented. I fixed that, too.

2006-08-16  Robert Schuster  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicTabbedPaneUI.java:
        (MouseHandler.mousePressed): Fixed indentation, intercept clicks on
        disabled tabs, do proper revalidation in WRAP_TAB_LAYOUT mode.

cya
Robert
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.50
diff -u -r1.50 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java	27 Jul 2006 01:28:41 -0000	1.50
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java	15 Aug 2006 23:44:28 -0000
@@ -298,47 +298,61 @@
           if(!decrButton.isEnabled())
             return;
         
-          // The scroll location may be zero but the offset
-          // greater than zero because of an adjustement to
-          // make a partially visible tab completely visible.
-          if (currentScrollLocation > 0)
-            currentScrollLocation--;
-        
-          // Set the offset back to 0 and recompute it.
-          currentScrollOffset = 0;
-
-          switch (placement)
-            {
-              case JTabbedPane.TOP:
-              case JTabbedPane.BOTTOM: 
-                // Take the tab area inset into account.
-                if (currentScrollLocation > 0)
-                  currentScrollOffset = getTabAreaInsets(placement).left;
-                // Recompute scroll offset.
-        for (int i = 0; i < currentScrollLocation; i++)
-          currentScrollOffset += rects[i].width;
-        break;
-        default:
-          // Take the tab area inset into account.
-          if (currentScrollLocation > 0)
-            currentScrollOffset = getTabAreaInsets(placement).top;
-        
-          for (int i = 0; i < currentScrollLocation; i++)
-            currentScrollOffset += rects[i].height;
-        }          
+           // The scroll location may be zero but the offset
+           // greater than zero because of an adjustement to
+           // make a partially visible tab completely visible.
+           if (currentScrollLocation > 0)
+             currentScrollLocation--;
+        
+           // Set the offset back to 0 and recompute it.
+           currentScrollOffset = 0;
+
+           switch (placement)
+             {
+               case JTabbedPane.TOP:
+               case JTabbedPane.BOTTOM: 
+                 // Take the tab area inset into account.
+                 if (currentScrollLocation > 0)
+                   currentScrollOffset = getTabAreaInsets(placement).left;
+                 // Recompute scroll offset.
+                 for (int i = 0; i < currentScrollLocation; i++)
+                   currentScrollOffset += rects[i].width;
+                 break;
+               default:
+                 // Take the tab area inset into account.
+                 if (currentScrollLocation > 0)
+                   currentScrollOffset = getTabAreaInsets(placement).top;
+                
+                 for (int i = 0; i < currentScrollLocation; i++)
+                   currentScrollOffset += rects[i].height;
+             }          
         
-       updateViewPosition();
-       updateButtons();
+           updateViewPosition();
+           updateButtons();
         
-       tabPane.repaint();
-      } else if (tabPane.isEnabled())
+           tabPane.repaint();
+        }
+      else if (tabPane.isEnabled())
         {
           int index = tabForCoordinate(tabPane, e.getX(), e.getY());
+          if (!tabPane.isEnabledAt(index))
+            return;
+          
           if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT
               && s == panel)
+            {
               scrollTab(index, placement);
+              
+              tabPane.setSelectedIndex(index);
+              tabPane.repaint();
+            }
+          else
+            {
+              tabPane.setSelectedIndex(index);
+              tabPane.revalidate();
+              tabPane.repaint();
+            }
           
-          tabPane.setSelectedIndex(index);
         }
       
     }

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to