/[classpath]/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by mark, Tue Jul 26 14:16:43 2005 UTC revision 1.25 by rabbit78, Wed Sep 14 15:07:40 2005 UTC
# Line 136  public class BasicTabbedPaneUI extends T Line 136  public class BasicTabbedPaneUI extends T
136    
137        if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)        if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
138          {          {
139            if (e.getSource() == incrButton)            if (e.getSource() == incrButton)
140              {              {
141                if (++currentScrollLocation >= tabCount)                if (++currentScrollLocation >= tabCount)
142                  currentScrollLocation = tabCount - 1;                  currentScrollLocation = tabCount - 1;
143                  
144                int width = 0;                int width = 0;
145                for (int i = currentScrollLocation - 1; i < tabCount; i++)                for (int i = currentScrollLocation - 1; i < tabCount; i++)
146                  width += rects[i].width;                  width += rects[i].width;
147                if (width < viewport.getWidth())                if (width < viewport.getWidth())
148                  // FIXME: Still getting mouse events after the button is disabled.                  // FIXME: Still getting mouse events after the button is disabled.
149      //  incrButton.setEnabled(false);                  //      incrButton.setEnabled(false);
150                  currentScrollLocation--;                  currentScrollLocation--;
151                else if (! decrButton.isEnabled())                else if (! decrButton.isEnabled())
152                  decrButton.setEnabled(true);                  decrButton.setEnabled(true);
153                tabPane.revalidate();                tabPane.revalidate();
154                tabPane.repaint();                tabPane.repaint();
155                return;                return;
156              }              }
157            else if (e.getSource() == decrButton)            else if (e.getSource() == decrButton)
158              {              {
159                if (--currentScrollLocation < 0)                if (--currentScrollLocation < 0)
160                  currentScrollLocation = 0;                  currentScrollLocation = 0;
161                if (currentScrollLocation == 0)                if (currentScrollLocation == 0)
162                  decrButton.setEnabled(false);                  decrButton.setEnabled(false);
163                else if (! incrButton.isEnabled())                else if (! incrButton.isEnabled())
164                  incrButton.setEnabled(true);                  incrButton.setEnabled(true);
165                tabPane.revalidate();                tabPane.revalidate();
166                tabPane.repaint();                tabPane.repaint();
167                return;                return;
168              }              }
169          }          }
170    
171        int index = tabForCoordinate(tabPane, x, y);        int index = tabForCoordinate(tabPane, x, y);
# Line 173  public class BasicTabbedPaneUI extends T Line 173  public class BasicTabbedPaneUI extends T
173        // We need to check since there are areas where tabs cannot be        // We need to check since there are areas where tabs cannot be
174        // e.g. in the inset area.        // e.g. in the inset area.
175        if (index != -1 && tabPane.isEnabledAt(index))        if (index != -1 && tabPane.isEnabledAt(index))
176          tabPane.setSelectedIndex(index);          tabPane.setSelectedIndex(index);
177        tabPane.revalidate();        tabPane.revalidate();
178        tabPane.repaint();        tabPane.repaint();
179      }      }
# Line 198  public class BasicTabbedPaneUI extends T Line 198  public class BasicTabbedPaneUI extends T
198      {      {
199        if (e.getPropertyName().equals("tabLayoutPolicy"))        if (e.getPropertyName().equals("tabLayoutPolicy"))
200          {          {
201            layoutManager = createLayoutManager();            layoutManager = createLayoutManager();
202              
203            tabPane.setLayout(layoutManager);            tabPane.setLayout(layoutManager);
204          }          }
205        else if (e.getPropertyName().equals("tabPlacement")        else if (e.getPropertyName().equals("tabPlacement")
206                 && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)            && tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
207          {          {
208            incrButton = createIncreaseButton();            incrButton = createIncreaseButton();
209            decrButton = createDecreaseButton();            decrButton = createDecreaseButton();
210          }          }
211        tabPane.layout();        tabPane.layout();
212        tabPane.repaint();        tabPane.repaint();
# Line 245  public class BasicTabbedPaneUI extends T Line 245  public class BasicTabbedPaneUI extends T
245    
246        if (tabPane.getSelectedIndex() != -1)        if (tabPane.getSelectedIndex() != -1)
247          {          {
248            Component visible = getVisibleComponent();            Component visible = getVisibleComponent();
249            Insets insets = getContentBorderInsets(tabPane.getTabPlacement());            Insets insets = getContentBorderInsets(tabPane.getTabPlacement());
250            if (visible != null)            if (visible != null)
251              visible.setBounds(contentRect.x + insets.left,              visible.setBounds(contentRect.x + insets.left,
252                                contentRect.y + insets.top,                                contentRect.y + insets.top,
253                                contentRect.width - insets.left - insets.right,                                contentRect.width - insets.left - insets.right,
254                                contentRect.height - insets.top - insets.bottom);                                contentRect.height - insets.top - insets.bottom);
255          }          }
256      }      }
257    
# Line 275  public class BasicTabbedPaneUI extends T Line 275  public class BasicTabbedPaneUI extends T
275        Dimension dims;        Dimension dims;
276        for (int i = 0; i < tabPane.getTabCount(); i++)        for (int i = 0; i < tabPane.getTabCount(); i++)
277          {          {
278            c = tabPane.getComponentAt(i);            c = tabPane.getComponentAt(i);
279            if (c == null)            if (c == null)
280              continue;              continue;
281            calcRect = c.getBounds();            calcRect = c.getBounds();
282            dims = c.getPreferredSize();            dims = c.getPreferredSize();
283            if (dims != null)            if (dims != null)
284              {              {
285                componentHeight = Math.max(componentHeight, dims.height);                componentHeight = Math.max(componentHeight, dims.height);
286                componentWidth = Math.max(componentWidth, dims.width);                componentWidth = Math.max(componentWidth, dims.width);
287              }              }
288          }          }
289        Insets insets = tabPane.getInsets();        Insets insets = tabPane.getInsets();
290    
291        if (tabPlacement == SwingConstants.TOP        if (tabPlacement == SwingConstants.TOP
292            || tabPlacement == SwingConstants.BOTTOM)            || tabPlacement == SwingConstants.BOTTOM)
293          {          {
294            int min = calculateMaxTabWidth(tabPlacement);            int min = calculateMaxTabWidth(tabPlacement);
295            width = Math.max(min, componentWidth);            width = Math.max(min, componentWidth);
296              
297            int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width);            int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width);
298            height = tabAreaHeight + componentHeight;            height = tabAreaHeight + componentHeight;
299          }          }
300        else        else
301          {          {
302            int min = calculateMaxTabHeight(tabPlacement);            int min = calculateMaxTabHeight(tabPlacement);
303            height = Math.max(min, componentHeight);            height = Math.max(min, componentHeight);
304              
305            int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height);            int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height);
306            width = tabAreaWidth + componentWidth;            width = tabAreaWidth + componentWidth;
307          }          }
308    
309        return new Dimension(width, height);        return new Dimension(width, height);
# Line 330  public class BasicTabbedPaneUI extends T Line 330  public class BasicTabbedPaneUI extends T
330      protected void calculateTabRects(int tabPlacement, int tabCount)      protected void calculateTabRects(int tabPlacement, int tabCount)
331      {      {
332        if (tabCount == 0)        if (tabCount == 0)
333          return;          return;
334        assureRectsCreated(tabCount);        assureRectsCreated(tabCount);
335    
336        FontMetrics fm = getFontMetrics();        FontMetrics fm = getFontMetrics();
# Line 343  public class BasicTabbedPaneUI extends T Line 343  public class BasicTabbedPaneUI extends T
343        if (tabPlacement == SwingConstants.TOP        if (tabPlacement == SwingConstants.TOP
344            || tabPlacement == SwingConstants.BOTTOM)            || tabPlacement == SwingConstants.BOTTOM)
345          {          {
346            int maxHeight = calculateMaxTabHeight(tabPlacement);            int maxHeight = calculateMaxTabHeight(tabPlacement);
347    
348            calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;            calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;
349            max = calcRect.width + tabAreaInsets.left + insets.left;            max = calcRect.width + tabAreaInsets.left + insets.left;
350            start += tabAreaInsets.left + insets.left;            start += tabAreaInsets.left + insets.left;
351            int width = 0;            int width = 0;
352            int runWidth = start;            int runWidth = start;
353    
354            for (int i = 0; i < tabCount; i++)            for (int i = 0; i < tabCount; i++)
355              {              {
356                width = calculateTabWidth(tabPlacement, i, fm);                width = calculateTabWidth(tabPlacement, i, fm);
357    
358                if (runWidth + width > max)                if (runWidth + width > max)
359                  {                  {
360                    runWidth = tabAreaInsets.left + insets.left                    runWidth = tabAreaInsets.left + insets.left
361                               + getTabRunIndent(tabPlacement, ++runs);                    + getTabRunIndent(tabPlacement, ++runs);
362                    rects[i] = new Rectangle(runWidth,                    rects[i] = new Rectangle(runWidth,
363                                             insets.top + tabAreaInsets.top,                                             insets.top + tabAreaInsets.top,
364                                             width, maxHeight);                                             width, maxHeight);
365                    runWidth += width;                    runWidth += width;
366                    if (runs > tabRuns.length - 1)                    if (runs > tabRuns.length - 1)
367                      expandTabRunsArray();                      expandTabRunsArray();
368                    tabRuns[runs] = i;                    tabRuns[runs] = i;
369                  }                  }
370                else                else
371                  {                  {
372                    rects[i] = new Rectangle(runWidth,                    rects[i] = new Rectangle(runWidth,
373                                             insets.top + tabAreaInsets.top,                                             insets.top + tabAreaInsets.top,
374                                             width, maxHeight);                                             width, maxHeight);
375                    runWidth += width;                    runWidth += width;
376                  }                  }
377              }              }
378            runs++;            runs++;
379            tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;            tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;
380            tabAreaRect.height = runs * maxTabHeight            tabAreaRect.height = runs * maxTabHeight
381                                 - (runs - 1) * tabRunOverlay            - (runs - 1) * tabRunOverlay
382                                 + tabAreaInsets.top + tabAreaInsets.bottom;            + tabAreaInsets.top + tabAreaInsets.bottom;
383            contentRect.width = tabAreaRect.width;            contentRect.width = tabAreaRect.width;
384            contentRect.height = tabPane.getHeight() - insets.top            contentRect.height = tabPane.getHeight() - insets.top
385                                 - insets.bottom - tabAreaRect.height;            - insets.bottom - tabAreaRect.height;
386            contentRect.x = insets.left;            contentRect.x = insets.left;
387            tabAreaRect.x = insets.left;            tabAreaRect.x = insets.left;
388            if (tabPlacement == SwingConstants.BOTTOM)            if (tabPlacement == SwingConstants.BOTTOM)
389              {              {
390                contentRect.y = insets.top;                contentRect.y = insets.top;
391                tabAreaRect.y = contentRect.y + contentRect.height;                tabAreaRect.y = contentRect.y + contentRect.height;
392              }              }
393            else            else
394              {              {
395                tabAreaRect.y = insets.top;                tabAreaRect.y = insets.top;
396                contentRect.y = tabAreaRect.y + tabAreaRect.height;                contentRect.y = tabAreaRect.y + tabAreaRect.height;
397              }              }
398          }          }
399        else        else
400          {          {
401            int maxWidth = calculateMaxTabWidth(tabPlacement);            int maxWidth = calculateMaxTabWidth(tabPlacement);
402            calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;            calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;
403            max = calcRect.height + tabAreaInsets.top + insets.top;            max = calcRect.height + tabAreaInsets.top + insets.top;
404    
405            int height = 0;            int height = 0;
406            start += tabAreaInsets.top + insets.top;            start += tabAreaInsets.top + insets.top;
407            int runHeight = start;            int runHeight = start;
408    
409            int fontHeight = fm.getHeight();            int fontHeight = fm.getHeight();
410    
411            for (int i = 0; i < tabCount; i++)            for (int i = 0; i < tabCount; i++)
412              {              {
413                height = calculateTabHeight(tabPlacement, i, fontHeight);                height = calculateTabHeight(tabPlacement, i, fontHeight);
414                if (runHeight + height > max)                if (runHeight + height > max)
415                  {                  {
416                    runHeight = tabAreaInsets.top + insets.top                    runHeight = tabAreaInsets.top + insets.top
417                                + getTabRunIndent(tabPlacement, ++runs);                    + getTabRunIndent(tabPlacement, ++runs);
418                    rects[i] = new Rectangle(insets.left + tabAreaInsets.left,                    rects[i] = new Rectangle(insets.left + tabAreaInsets.left,
419                                             runHeight, maxWidth, height);                                             runHeight, maxWidth, height);
420                    runHeight += height;                    runHeight += height;
421                    if (runs > tabRuns.length - 1)                    if (runs > tabRuns.length - 1)
422                      expandTabRunsArray();                      expandTabRunsArray();
423                    tabRuns[runs] = i;                    tabRuns[runs] = i;
424                  }                  }
425                else                else
426                  {                  {
427                    rects[i] = new Rectangle(insets.left + tabAreaInsets.left,                    rects[i] = new Rectangle(insets.left + tabAreaInsets.left,
428                                             runHeight, maxWidth, height);                                             runHeight, maxWidth, height);
429                    runHeight += height;                    runHeight += height;
430                  }                  }
431              }              }
432            runs++;            runs++;
433    
434            tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay            tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay
435                                + tabAreaInsets.left + tabAreaInsets.right;            + tabAreaInsets.left + tabAreaInsets.right;
436            tabAreaRect.height = tabPane.getHeight() - insets.top            tabAreaRect.height = tabPane.getHeight() - insets.top
437                                 - insets.bottom;            - insets.bottom;
438            tabAreaRect.y = insets.top;            tabAreaRect.y = insets.top;
439            contentRect.width = tabPane.getWidth() - insets.left - insets.right            contentRect.width = tabPane.getWidth() - insets.left - insets.right
440                                - tabAreaRect.width;            - tabAreaRect.width;
441            contentRect.height = tabAreaRect.height;            contentRect.height = tabAreaRect.height;
442            contentRect.y = insets.top;            contentRect.y = insets.top;
443            if (tabPlacement == SwingConstants.LEFT)            if (tabPlacement == SwingConstants.LEFT)
444              {              {
445                tabAreaRect.x = insets.left;                tabAreaRect.x = insets.left;
446                contentRect.x = tabAreaRect.x + tabAreaRect.width;                contentRect.x = tabAreaRect.x + tabAreaRect.width;
447              }              }
448            else            else
449              {              {
450                contentRect.x = insets.left;                contentRect.x = insets.left;
451                tabAreaRect.x = contentRect.x + contentRect.width;                tabAreaRect.x = contentRect.x + contentRect.width;
452              }              }
453          }          }
454        runCount = runs;        runCount = runs;
455    
# Line 457  public class BasicTabbedPaneUI extends T Line 457  public class BasicTabbedPaneUI extends T
457        normalizeTabRuns(tabPlacement, tabCount, start, max);        normalizeTabRuns(tabPlacement, tabCount, start, max);
458        selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex());        selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex());
459        if (shouldRotateTabRuns(tabPlacement))        if (shouldRotateTabRuns(tabPlacement))
460          rotateTabRuns(tabPlacement, selectedRun);          rotateTabRuns(tabPlacement, selectedRun);
461    
462        // Need to pad the runs and move them to the correct location.        // Need to pad the runs and move them to the correct location.
463        for (int i = 0; i < runCount; i++)        for (int i = 0; i < runCount; i++)
464          {          {
465            int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1;            int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1;
466            if (first == tabCount)            if (first == tabCount)
467              first = 0;              first = 0;
468            int last = lastTabInRun(tabCount, i);            int last = lastTabInRun(tabCount, i);
469            if (shouldPadTabRun(tabPlacement, i))            if (shouldPadTabRun(tabPlacement, i))
470              padTabRun(tabPlacement, first, last, max);              padTabRun(tabPlacement, first, last, max);
471    
472            // Done padding, now need to move it.            // Done padding, now need to move it.
473            if (tabPlacement == SwingConstants.TOP && i > 0)            if (tabPlacement == SwingConstants.TOP && i > 0)
474              {              {
475                for (int j = first; j <= last; j++)                for (int j = first; j <= last; j++)
476                  rects[j].y += (runCount - i) * maxTabHeight                  rects[j].y += (runCount - i) * maxTabHeight
477                  - (runCount - i) * tabRunOverlay;                  - (runCount - i) * tabRunOverlay;
478              }              }
479    
480            if (tabPlacement == SwingConstants.BOTTOM)            if (tabPlacement == SwingConstants.BOTTOM)
481              {              {
482                int height = tabPane.getBounds().height - insets.bottom                int height = tabPane.getBounds().height - insets.bottom
483                             - tabAreaInsets.bottom;                - tabAreaInsets.bottom;
484                int adjustment;                int adjustment;
485                if (i == 0)                if (i == 0)
486                  adjustment = height - maxTabHeight;                  adjustment = height - maxTabHeight;
487                else                else
488                  adjustment = height - (runCount - i + 1) * maxTabHeight                  adjustment = height - (runCount - i + 1) * maxTabHeight
489                               - (runCount - i) * tabRunOverlay;                  - (runCount - i) * tabRunOverlay;
490    
491                for (int j = first; j <= last; j++)                for (int j = first; j <= last; j++)
492                  rects[j].y = adjustment;                  rects[j].y = adjustment;
493              }              }
494    
495            if (tabPlacement == SwingConstants.LEFT && i > 0)            if (tabPlacement == SwingConstants.LEFT && i > 0)
496              {              {
497                for (int j = first; j <= last; j++)                for (int j = first; j <= last; j++)
498                  rects[j].x += (runCount - i) * maxTabWidth                  rects[j].x += (runCount - i) * maxTabWidth
499                  - (runCount - i) * tabRunOverlay;                  - (runCount - i) * tabRunOverlay;
500              }              }
501    
502            if (tabPlacement == SwingConstants.RIGHT)            if (tabPlacement == SwingConstants.RIGHT)
503              {              {
504                int width = tabPane.getBounds().width - insets.right                int width = tabPane.getBounds().width - insets.right
505                            - tabAreaInsets.right;                - tabAreaInsets.right;
506                int adjustment;                int adjustment;
507                if (i == 0)                if (i == 0)
508                  adjustment = width - maxTabWidth;                  adjustment = width - maxTabWidth;
509                else                else
510                  adjustment = width - (runCount - i + 1) * maxTabWidth                  adjustment = width - (runCount - i + 1) * maxTabWidth
511                               + (runCount - i) * tabRunOverlay;                  + (runCount - i) * tabRunOverlay;
512    
513                for (int j = first; j <= last; j++)                for (int j = first; j <= last; j++)
514                  rects[j].x = adjustment;                  rects[j].x = adjustment;
515              }              }
516          }          }
517        padSelectedTab(tabPlacement, tabPane.getSelectedIndex());        padSelectedTab(tabPlacement, tabPane.getSelectedIndex());
518      }      }
# Line 565  public class BasicTabbedPaneUI extends T Line 565  public class BasicTabbedPaneUI extends T
565        if (tabPlacement == SwingUtilities.TOP        if (tabPlacement == SwingUtilities.TOP
566            || tabPlacement == SwingUtilities.BOTTOM)            || tabPlacement == SwingUtilities.BOTTOM)
567          {          {
568            // We should only do this for runCount - 1, cause we can only shift that many times between            // We should only do this for runCount - 1, cause we can only shift that many times between
569            // runs.            // runs.
570            for (int i = 1; i < runCount; i++)            for (int i = 1; i < runCount; i++)
571              {              {
572                Rectangle currRun = rects[lastTabInRun(tabCount, i)];                Rectangle currRun = rects[lastTabInRun(tabCount, i)];
573                Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];                Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];
574                int spaceInCurr = currRun.x + currRun.width;                int spaceInCurr = currRun.x + currRun.width;
575                int spaceInNext = nextRun.x + nextRun.width;                int spaceInNext = nextRun.x + nextRun.width;
576    
577                int diffNow = spaceInCurr - spaceInNext;                int diffNow = spaceInCurr - spaceInNext;
578                int diffLater = (spaceInCurr - currRun.width)                int diffLater = (spaceInCurr - currRun.width)
579                                - (spaceInNext + currRun.width);                - (spaceInNext + currRun.width);
580                while (Math.abs(diffLater) < Math.abs(diffNow)                while (Math.abs(diffLater) < Math.abs(diffNow)
581                       && spaceInNext + currRun.width < max)                    && spaceInNext + currRun.width < max)
582                  {                  {
583                    tabRuns[i]--;                    tabRuns[i]--;
584                    spaceInNext += currRun.width;                    spaceInNext += currRun.width;
585                    spaceInCurr -= currRun.width;                    spaceInCurr -= currRun.width;
586                    currRun = rects[lastTabInRun(tabCount, i)];                    currRun = rects[lastTabInRun(tabCount, i)];
587                    diffNow = spaceInCurr - spaceInNext;                    diffNow = spaceInCurr - spaceInNext;
588                    diffLater = (spaceInCurr - currRun.width)                    diffLater = (spaceInCurr - currRun.width)
589                                - (spaceInNext + currRun.width);                    - (spaceInNext + currRun.width);
590                  }                  }
591    
592                // Fix the bounds.                // Fix the bounds.
593                int first = lastTabInRun(tabCount, i) + 1;                int first = lastTabInRun(tabCount, i) + 1;
594                int last = lastTabInRun(tabCount, getNextTabRun(i));                int last = lastTabInRun(tabCount, getNextTabRun(i));
595                int currX = tabAreaInsets.left;                int currX = tabAreaInsets.left;
596                for (int j = first; j <= last; j++)                for (int j = first; j <= last; j++)
597                  {                  {
598                    rects[j].x = currX;                    rects[j].x = currX;
599                    currX += rects[j].width;                    currX += rects[j].width;
600                  }                  }
601              }              }
602          }          }
603        else        else
604          {          {
605            for (int i = 1; i < runCount; i++)            for (int i = 1; i < runCount; i++)
606              {              {
607                Rectangle currRun = rects[lastTabInRun(tabCount, i)];                Rectangle currRun = rects[lastTabInRun(tabCount, i)];
608                Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];                Rectangle nextRun = rects[lastTabInRun(tabCount, getNextTabRun(i))];
609                int spaceInCurr = currRun.y + currRun.height;                int spaceInCurr = currRun.y + currRun.height;
610                int spaceInNext = nextRun.y + nextRun.height;                int spaceInNext = nextRun.y + nextRun.height;
611    
612                int diffNow = spaceInCurr - spaceInNext;                int diffNow = spaceInCurr - spaceInNext;
613                int diffLater = (spaceInCurr - currRun.height)                int diffLater = (spaceInCurr - currRun.height)
614                                - (spaceInNext + currRun.height);                - (spaceInNext + currRun.height);
615                while (Math.abs(diffLater) < Math.abs(diffNow)                while (Math.abs(diffLater) < Math.abs(diffNow)
616                       && spaceInNext + currRun.height < max)                    && spaceInNext + currRun.height < max)
617                  {                  {
618                    tabRuns[i]--;                    tabRuns[i]--;
619                    spaceInNext += currRun.height;                    spaceInNext += currRun.height;
620                    spaceInCurr -= currRun.height;                    spaceInCurr -= currRun.height;
621                    currRun = rects[lastTabInRun(tabCount, i)];                    currRun = rects[lastTabInRun(tabCount, i)];
622                    diffNow = spaceInCurr - spaceInNext;                    diffNow = spaceInCurr - spaceInNext;
623                    diffLater = (spaceInCurr - currRun.height)                    diffLater = (spaceInCurr - currRun.height)
624                                - (spaceInNext + currRun.height);                    - (spaceInNext + currRun.height);
625                  }                  }
626    
627                int first = lastTabInRun(tabCount, i) + 1;                int first = lastTabInRun(tabCount, i) + 1;
628                int last = lastTabInRun(tabCount, getNextTabRun(i));                int last = lastTabInRun(tabCount, getNextTabRun(i));
629                int currY = tabAreaInsets.top;                int currY = tabAreaInsets.top;
630                for (int j = first; j <= last; j++)                for (int j = first; j <= last; j++)
631                  {                  {
632                    rects[j].y = currY;                    rects[j].y = currY;
633                    currY += rects[j].height;                    currY += rects[j].height;
634                  }                  }
635              }              }
636          }          }
637      }      }
638    
# Line 673  public class BasicTabbedPaneUI extends T Line 673  public class BasicTabbedPaneUI extends T
673        if (tabPlacement == SwingConstants.TOP        if (tabPlacement == SwingConstants.TOP
674            || tabPlacement == SwingConstants.BOTTOM)            || tabPlacement == SwingConstants.BOTTOM)
675          {          {
676            int runWidth = rects[end].x + rects[end].width;            int runWidth = rects[end].x + rects[end].width;
677            int spaceRemaining = max - runWidth;            int spaceRemaining = max - runWidth;
678            int numTabs = end - start + 1;            int numTabs = end - start + 1;
679    
680            // now divvy up the space.            // now divvy up the space.
681            int spaceAllocated = spaceRemaining / numTabs;            int spaceAllocated = spaceRemaining / numTabs;
682            int currX = rects[start].x;            int currX = rects[start].x;
683            for (int i = start; i <= end; i++)            for (int i = start; i <= end; i++)
684              {              {
685                rects[i].x = currX;                rects[i].x = currX;
686                rects[i].width += spaceAllocated;                rects[i].width += spaceAllocated;
687                currX += rects[i].width;                currX += rects[i].width;
688                // This is used because since the spaceAllocated                // This is used because since the spaceAllocated
689                // variable is an int, it rounds down. Sometimes,                // variable is an int, it rounds down. Sometimes,
690                // we don't fill an entire row, so we make it do                // we don't fill an entire row, so we make it do
691                // so now.                // so now.
692                if (i == end && rects[i].x + rects[i].width != max)                if (i == end && rects[i].x + rects[i].width != max)
693                  rects[i].width = max - rects[i].x;                  rects[i].width = max - rects[i].x;
694              }              }
695          }          }
696        else        else
697          {          {
698            int runHeight = rects[end].y + rects[end].height;            int runHeight = rects[end].y + rects[end].height;
699            int spaceRemaining = max - runHeight;            int spaceRemaining = max - runHeight;
700            int numTabs = end - start + 1;            int numTabs = end - start + 1;
701    
702            int spaceAllocated = spaceRemaining / numTabs;            int spaceAllocated = spaceRemaining / numTabs;
703            int currY = rects[start].y;            int currY = rects[start].y;
704            for (int i = start; i <= end; i++)            for (int i = start; i <= end; i++)
705              {              {
706                rects[i].y = currY;                rects[i].y = currY;
707                rects[i].height += spaceAllocated;                rects[i].height += spaceAllocated;
708                currY += rects[i].height;                currY += rects[i].height;
709                if (i == end && rects[i].y + rects[i].height != max)                if (i == end && rects[i].y + rects[i].height != max)
710                  rects[i].height = max - rects[i].y;                  rects[i].height = max - rects[i].y;
711              }              }
712          }          }
713      }      }
714    
# Line 736  public class BasicTabbedPaneUI extends T Line 736  public class BasicTabbedPaneUI extends T
736      protected int preferredTabAreaHeight(int tabPlacement, int width)      protected int preferredTabAreaHeight(int tabPlacement, int width)
737      {      {
738        if (tabPane.getTabCount() == 0)        if (tabPane.getTabCount() == 0)
739          return calculateTabAreaHeight(tabPlacement, 0, 0);          return calculateTabAreaHeight(tabPlacement, 0, 0);
740    
741        int runs = 0;        int runs = 0;
742        int runWidth = 0;        int runWidth = 0;
# Line 758  public class BasicTabbedPaneUI extends T Line 758  public class BasicTabbedPaneUI extends T
758        // be IF we got our desired width.        // be IF we got our desired width.
759        for (int i = 0; i < tabPane.getTabCount(); i++)        for (int i = 0; i < tabPane.getTabCount(); i++)
760          {          {
761            tabWidth = calculateTabWidth(tabPlacement, i, fm);            tabWidth = calculateTabWidth(tabPlacement, i, fm);
762            if (runWidth + tabWidth > width)            if (runWidth + tabWidth > width)
763              {              {
764                runWidth = tabWidth;                runWidth = tabWidth;
765                runs++;                runs++;
766              }              }
767            else            else
768              runWidth += tabWidth;              runWidth += tabWidth;
769          }          }
770        runs++;        runs++;
771    
# Line 787  public class BasicTabbedPaneUI extends T Line 787  public class BasicTabbedPaneUI extends T
787      protected int preferredTabAreaWidth(int tabPlacement, int height)      protected int preferredTabAreaWidth(int tabPlacement, int height)
788      {      {
789        if (tabPane.getTabCount() == 0)        if (tabPane.getTabCount() == 0)
790          return calculateTabAreaHeight(tabPlacement, 0, 0);          return calculateTabAreaHeight(tabPlacement, 0, 0);
791    
792        int runs = 0;        int runs = 0;
793        int runHeight = 0;        int runHeight = 0;
# Line 804  public class BasicTabbedPaneUI extends T Line 804  public class BasicTabbedPaneUI extends T
804    
805        for (int i = 0; i < tabPane.getTabCount(); i++)        for (int i = 0; i < tabPane.getTabCount(); i++)
806          {          {
807            tabHeight = calculateTabHeight(tabPlacement, i, fontHeight);            tabHeight = calculateTabHeight(tabPlacement, i, fontHeight);
808            if (runHeight + tabHeight > height)            if (runHeight + tabHeight > height)
809              {              {
810                runHeight = tabHeight;                runHeight = tabHeight;
811                runs++;                runs++;
812              }              }
813            else            else
814              runHeight += tabHeight;              runHeight += tabHeight;
815          }          }
816        runs++;        runs++;
817    
# Line 831  public class BasicTabbedPaneUI extends T Line 831  public class BasicTabbedPaneUI extends T
831      protected void rotateTabRuns(int tabPlacement, int selectedRun)      protected void rotateTabRuns(int tabPlacement, int selectedRun)
832      {      {
833        if (runCount == 1 || selectedRun == 1 || selectedRun == -1)        if (runCount == 1 || selectedRun == 1 || selectedRun == -1)
834          return;          return;
835        int[] newTabRuns = new int[tabRuns.length];        int[] newTabRuns = new int[tabRuns.length];
836        int currentRun = selectedRun;        int currentRun = selectedRun;
837        int i = 1;        int i = 1;
838        do        do
839          {          {
840            newTabRuns[i] = tabRuns[currentRun];            newTabRuns[i] = tabRuns[currentRun];
841            currentRun = getNextTabRun(currentRun);            currentRun = getNextTabRun(currentRun);
842            i++;            i++;
843          }          }
844        while (i < runCount);        while (i < runCount);
845        if (runCount > 1)        if (runCount > 1)
846          newTabRuns[0] = tabRuns[currentRun];          newTabRuns[0] = tabRuns[currentRun];
847    
848        tabRuns = newTabRuns;        tabRuns = newTabRuns;
849        BasicTabbedPaneUI.this.selectedRun = 1;        BasicTabbedPaneUI.this.selectedRun = 1;
# Line 902  public class BasicTabbedPaneUI extends T Line 902  public class BasicTabbedPaneUI extends T
902      protected int preferredTabAreaHeight(int tabPlacement, int width)      protected int preferredTabAreaHeight(int tabPlacement, int width)
903      {      {
904        if (tabPane.getTabCount() == 0)        if (tabPane.getTabCount() == 0)
905          return calculateTabAreaHeight(tabPlacement, 0, 0);          return calculateTabAreaHeight(tabPlacement, 0, 0);
906    
907        int runs = 1;        int runs = 1;
908    
# Line 923  public class BasicTabbedPaneUI extends T Line 923  public class BasicTabbedPaneUI extends T
923      protected int preferredTabAreaWidth(int tabPlacement, int height)      protected int preferredTabAreaWidth(int tabPlacement, int height)
924      {      {
925        if (tabPane.getTabCount() == 0)        if (tabPane.getTabCount() == 0)
926          return calculateTabAreaHeight(tabPlacement, 0, 0);          return calculateTabAreaHeight(tabPlacement, 0, 0);
927    
928        int runs = 1;        int runs = 1;
929    
# Line 944  public class BasicTabbedPaneUI extends T Line 944  public class BasicTabbedPaneUI extends T
944      protected void calculateTabRects(int tabPlacement, int tabCount)      protected void calculateTabRects(int tabPlacement, int tabCount)
945      {      {
946        if (tabCount == 0)        if (tabCount == 0)
947          return;          return;
948        assureRectsCreated(tabCount);        assureRectsCreated(tabCount);
949    
950        FontMetrics fm = getFontMetrics();        FontMetrics fm = getFontMetrics();
# Line 958  public class BasicTabbedPaneUI extends T Line 958  public class BasicTabbedPaneUI extends T
958        if (tabPlacement == SwingConstants.TOP        if (tabPlacement == SwingConstants.TOP
959            || tabPlacement == SwingConstants.BOTTOM)            || tabPlacement == SwingConstants.BOTTOM)
960          {          {
961            int maxHeight = calculateMaxTabHeight(tabPlacement);            int maxHeight = calculateMaxTabHeight(tabPlacement);
962            calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;            calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;
963            max = calcRect.width + tabAreaInsets.left + insets.left;            max = calcRect.width + tabAreaInsets.left + insets.left;
964            start = tabAreaInsets.left + insets.left;            start = tabAreaInsets.left + insets.left;
965            int width = 0;            int width = 0;
966            int runWidth = start;            int runWidth = start;
967            top = insets.top + tabAreaInsets.top;            top = insets.top + tabAreaInsets.top;
968            for (int i = 0; i < tabCount; i++)            for (int i = 0; i < tabCount; i++)
969              {              {
970                width = calculateTabWidth(tabPlacement, i, fm);                width = calculateTabWidth(tabPlacement, i, fm);
971    
972                rects[i] = new Rectangle(runWidth, top, width, maxHeight);                rects[i] = new Rectangle(runWidth, top, width, maxHeight);
973                runWidth += width;                runWidth += width;
974              }              }
975            tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;            tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;
976            tabAreaRect.height = runs * maxTabHeight            tabAreaRect.height = runs * maxTabHeight
977                                 - (runs - 1) * tabRunOverlay            - (runs - 1) * tabRunOverlay
978                                 + tabAreaInsets.top + tabAreaInsets.bottom;            + tabAreaInsets.top + tabAreaInsets.bottom;
979            contentRect.width = tabAreaRect.width;            contentRect.width = tabAreaRect.width;
980            contentRect.height = tabPane.getHeight() - insets.top            contentRect.height = tabPane.getHeight() - insets.top
981                                 - insets.bottom - tabAreaRect.height;            - insets.bottom - tabAreaRect.height;
982            contentRect.x = insets.left;            contentRect.x = insets.left;
983            tabAreaRect.x = insets.left;            tabAreaRect.x = insets.left;
984            if (tabPlacement == SwingConstants.BOTTOM)            if (tabPlacement == SwingConstants.BOTTOM)
985              {              {
986                contentRect.y = insets.top;                contentRect.y = insets.top;
987                tabAreaRect.y = contentRect.y + contentRect.height;                tabAreaRect.y = contentRect.y + contentRect.height;
988              }              }
989            else            else
990              {              {
991                tabAreaRect.y = insets.top;                tabAreaRect.y = insets.top;
992                contentRect.y = tabAreaRect.y + tabAreaRect.height;                contentRect.y = tabAreaRect.y + tabAreaRect.height;
993              }              }
994          }          }
995        else        else
996          {          {
997            int maxWidth = calculateMaxTabWidth(tabPlacement);            int maxWidth = calculateMaxTabWidth(tabPlacement);
998    
999            calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;            calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;
1000            max = calcRect.height + tabAreaInsets.top;            max = calcRect.height + tabAreaInsets.top;
1001            int height = 0;            int height = 0;
1002            start = tabAreaInsets.top + insets.top;            start = tabAreaInsets.top + insets.top;
1003            int runHeight = start;            int runHeight = start;
1004            int fontHeight = fm.getHeight();            int fontHeight = fm.getHeight();
1005            top = insets.left + tabAreaInsets.left;            top = insets.left + tabAreaInsets.left;
1006            for (int i = 0; i < tabCount; i++)            for (int i = 0; i < tabCount; i++)
1007              {              {
1008                height = calculateTabHeight(tabPlacement, i, fontHeight);                height = calculateTabHeight(tabPlacement, i, fontHeight);
1009                rects[i] = new Rectangle(top, runHeight, maxWidth, height);                rects[i] = new Rectangle(top, runHeight, maxWidth, height);
1010                runHeight += height;                runHeight += height;
1011              }              }
1012            tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay            tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay
1013                                + tabAreaInsets.left + tabAreaInsets.right;            + tabAreaInsets.left + tabAreaInsets.right;
1014            tabAreaRect.height = tabPane.getHeight() - insets.top            tabAreaRect.height = tabPane.getHeight() - insets.top
1015                                 - insets.bottom;            - insets.bottom;
1016            tabAreaRect.y = insets.top;            tabAreaRect.y = insets.top;
1017            contentRect.width = tabPane.getWidth() - insets.left - insets.right            contentRect.width = tabPane.getWidth() - insets.left - insets.right
1018                                - tabAreaRect.width;            - tabAreaRect.width;
1019            contentRect.height = tabAreaRect.height;            contentRect.height = tabAreaRect.height;
1020            contentRect.y = insets.top;            contentRect.y = insets.top;
1021            if (tabPlacement == SwingConstants.LEFT)            if (tabPlacement == SwingConstants.LEFT)
1022              {              {
1023                tabAreaRect.x = insets.left;                tabAreaRect.x = insets.left;
1024                contentRect.x = tabAreaRect.x + tabAreaRect.width;                contentRect.x = tabAreaRect.x + tabAreaRect.width;
1025              }              }
1026            else            else
1027              {              {
1028                contentRect.x = insets.left;                contentRect.x = insets.left;
1029                tabAreaRect.x = contentRect.x + contentRect.width;                tabAreaRect.x = contentRect.x + contentRect.width;
1030              }              }
1031          }          }
1032        runCount = runs;        runCount = runs;
1033    
# Line 1047  public class BasicTabbedPaneUI extends T Line 1047  public class BasicTabbedPaneUI extends T
1047        int tabCount = tabPane.getTabCount();        int tabCount = tabPane.getTabCount();
1048        Point p = null;        Point p = null;
1049        if (tabCount == 0)        if (tabCount == 0)
1050          return;          return;
1051        int tabPlacement = tabPane.getTabPlacement();        int tabPlacement = tabPane.getTabPlacement();
1052        incrButton.hide();        incrButton.hide();
1053        decrButton.hide();        decrButton.hide();
1054        if (tabPlacement == SwingConstants.TOP        if (tabPlacement == SwingConstants.TOP
1055            || tabPlacement == SwingConstants.BOTTOM)            || tabPlacement == SwingConstants.BOTTOM)
1056          {          {
1057            if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x            if (tabAreaRect.x + tabAreaRect.width < rects[tabCount - 1].x
1058                + rects[tabCount - 1].width)                + rects[tabCount - 1].width)
1059              {              {
1060                Dimension incrDims = incrButton.getPreferredSize();                Dimension incrDims = incrButton.getPreferredSize();
1061                Dimension decrDims = decrButton.getPreferredSize();                Dimension decrDims = decrButton.getPreferredSize();
1062    
1063                decrButton.setBounds(tabAreaRect.x + tabAreaRect.width                decrButton.setBounds(tabAreaRect.x + tabAreaRect.width
1064                                     - incrDims.width - decrDims.width,                                     - incrDims.width - decrDims.width,
1065                                     tabAreaRect.y, decrDims.width,                                     tabAreaRect.y, decrDims.width,
1066                                     tabAreaRect.height);                                     tabAreaRect.height);
1067                incrButton.setBounds(tabAreaRect.x + tabAreaRect.width                incrButton.setBounds(tabAreaRect.x + tabAreaRect.width
1068                                     - incrDims.width, tabAreaRect.y,                                     - incrDims.width, tabAreaRect.y,
1069                                     decrDims.width, tabAreaRect.height);                                     decrDims.width, tabAreaRect.height);
1070    
1071                tabAreaRect.width -= decrDims.width + incrDims.width;                tabAreaRect.width -= decrDims.width + incrDims.width;
1072                incrButton.show();                incrButton.show();
1073                decrButton.show();                decrButton.show();
1074              }              }
1075          }          }
1076    
1077        if (tabPlacement == SwingConstants.LEFT        if (tabPlacement == SwingConstants.LEFT
1078            || tabPlacement == SwingConstants.RIGHT)            || tabPlacement == SwingConstants.RIGHT)
1079          {          {
1080            if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y            if (tabAreaRect.y + tabAreaRect.height < rects[tabCount - 1].y
1081                + rects[tabCount - 1].height)                + rects[tabCount - 1].height)
1082              {              {
1083                Dimension incrDims = incrButton.getPreferredSize();                Dimension incrDims = incrButton.getPreferredSize();
1084                Dimension decrDims = decrButton.getPreferredSize();                Dimension decrDims = decrButton.getPreferredSize();
1085    
1086                decrButton.setBounds(tabAreaRect.x,                decrButton.setBounds(tabAreaRect.x,
1087                                     tabAreaRect.y + tabAreaRect.height                                     tabAreaRect.y + tabAreaRect.height
1088                                     - incrDims.height - decrDims.height,                                     - incrDims.height - decrDims.height,
1089                                     tabAreaRect.width, decrDims.height);                                     tabAreaRect.width, decrDims.height);
1090                incrButton.setBounds(tabAreaRect.x,                incrButton.setBounds(tabAreaRect.x,
1091                                     tabAreaRect.y + tabAreaRect.height                                     tabAreaRect.y + tabAreaRect.height
1092                                     - incrDims.height, tabAreaRect.width,                                     - incrDims.height, tabAreaRect.width,
1093                                     incrDims.height);                                     incrDims.height);
1094    
1095                tabAreaRect.height -= decrDims.height + incrDims.height;                tabAreaRect.height -= decrDims.height + incrDims.height;
1096                incrButton.show();                incrButton.show();
1097                decrButton.show();                decrButton.show();
1098              }              }
1099          }          }
1100        viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width,        viewport.setBounds(tabAreaRect.x, tabAreaRect.y, tabAreaRect.width,
1101                           tabAreaRect.height);                           tabAreaRect.height);
1102        int tabC = tabPane.getTabCount() - 1;        int tabC = tabPane.getTabCount() - 1;
1103        if (tabCount > 0)        if (tabCount > 0)
1104          {          {
1105            int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width);            int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width);
1106            int h = Math.max(rects[tabC].height, tabAreaRect.height);            int h = Math.max(rects[tabC].height, tabAreaRect.height);
1107            p = findPointForIndex(currentScrollLocation);            p = findPointForIndex(currentScrollLocation);
1108              
1109            // we want to cover that entire space so that borders that run under            // we want to cover that entire space so that borders that run under
1110            // the tab area don't show up when we move the viewport around.            // the tab area don't show up when we move the viewport around.
1111            panel.setSize(w + p.x, h + p.y);            panel.setSize(w + p.x, h + p.y);
1112          }          }
1113        viewport.setViewPosition(p);        viewport.setViewPosition(p);
1114        viewport.repaint();        viewport.repaint();
# Line 1160  public class BasicTabbedPaneUI extends T Line 1160  public class BasicTabbedPaneUI extends T
1160         */         */
1161        public void paint(Graphics g, JComponent c)        public void paint(Graphics g, JComponent c)
1162        {        {
1163          paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());          paintTabArea(g, tabPane.getTabPlacement(), tabPane.getSelectedIndex());
1164        }        }
1165      }      }
1166    
# Line 1407  public class BasicTabbedPaneUI extends T Line 1407  public class BasicTabbedPaneUI extends T
1407    
1408      if (tabPlacement == TOP || tabPlacement == BOTTOM)      if (tabPlacement == TOP || tabPlacement == BOTTOM)
1409        {        {
1410          if (index > 0)          if (index > 0)
1411            {            {
1412              w += rects[index - 1].x + rects[index - 1].width;              w += rects[index - 1].x + rects[index - 1].width;
1413              if (index > selectedIndex)              if (index > selectedIndex)
1414                w -= insets.left + insets.right;                w -= insets.left + insets.right;
1415            }            }
1416        }        }
1417    
1418      else      else
1419        {        {
1420          if (index > 0)          if (index > 0)
1421            {            {
1422              h += rects[index - 1].y + rects[index - 1].height;              h += rects[index - 1].y + rects[index - 1].height;
1423              if (index > selectedIndex)              if (index > selectedIndex)
1424                h -= insets.top + insets.bottom;                h -= insets.top + insets.bottom;
1425            }            }
1426        }        }
1427    
1428      Point p = new Point(w, h);      Point p = new Point(w, h);
# Line 1451  public class BasicTabbedPaneUI extends T Line 1451  public class BasicTabbedPaneUI extends T
1451      super.installUI(c);      super.installUI(c);
1452      if (c instanceof JTabbedPane)      if (c instanceof JTabbedPane)
1453        {        {
1454          tabPane = (JTabbedPane) c;          tabPane = (JTabbedPane) c;
1455            
1456          installComponents();          installComponents();
1457          installDefaults();          installDefaults();
1458          installListeners();          installListeners();
1459          installKeyboardActions();          installKeyboardActions();
1460            
1461          layoutManager = createLayoutManager();          layoutManager = createLayoutManager();
1462          tabPane.setLayout(layoutManager);          tabPane.setLayout(layoutManager);
1463          tabPane.layout();          tabPane.layout();
1464        }        }
1465    }    }
1466    
# Line 1495  public class BasicTabbedPaneUI extends T Line 1495  public class BasicTabbedPaneUI extends T
1495        return new TabbedPaneLayout();        return new TabbedPaneLayout();
1496      else      else
1497        {        {
1498          incrButton = createIncreaseButton();          incrButton = createIncreaseButton();
1499          decrButton = createDecreaseButton();          decrButton = createDecreaseButton();
1500          viewport = new ScrollingViewport();          viewport = new ScrollingViewport();
1501          viewport.setLayout(null);          viewport.setLayout(null);
1502          panel = new ScrollingPanel();          panel = new ScrollingPanel();
1503          viewport.setView(panel);          viewport.setView(panel);
1504          tabPane.add(incrButton);          tabPane.add(incrButton);
1505          tabPane.add(decrButton);          tabPane.add(decrButton);
1506          tabPane.add(viewport);          tabPane.add(viewport);
1507          currentScrollLocation = 0;          currentScrollLocation = 0;
1508          decrButton.setEnabled(false);          decrButton.setEnabled(false);
1509          panel.addMouseListener(mouseListener);          panel.addMouseListener(mouseListener);
1510          incrButton.addMouseListener(mouseListener);          incrButton.addMouseListener(mouseListener);
1511          decrButton.addMouseListener(mouseListener);          decrButton.addMouseListener(mouseListener);
1512          viewport.setBackground(Color.LIGHT_GRAY);          viewport.setBackground(Color.LIGHT_GRAY);
1513    
1514          return new TabbedPaneScrollLayout();          return new TabbedPaneScrollLayout();
1515        }        }
1516    }    }
1517    
# Line 1744  public class BasicTabbedPaneUI extends T Line 1744  public class BasicTabbedPaneUI extends T
1744        currRun = 0;        currRun = 0;
1745      for (int i = 0; i < runCount; i++)      for (int i = 0; i < runCount; i++)
1746        {        {
1747          int first = lastTabInRun(tabCount, getPreviousTabRun(currRun)) + 1;          int first = lastTabInRun(tabCount, getPreviousTabRun(currRun)) + 1;
1748          if (isScroll)          if (isScroll)
1749            first = currentScrollLocation;            first = currentScrollLocation;
1750          else if (first == tabCount)          else if (first == tabCount)
1751            first = 0;            first = 0;
1752          int last = lastTabInRun(tabCount, currRun);          int last = lastTabInRun(tabCount, currRun);
1753          if (isScroll)          if (isScroll)
1754            {            {
1755              for (int k = first; k < tabCount; k++)              for (int k = first; k < tabCount; k++)
1756                {                {
1757                  if (rects[k].x + rects[k].width - rects[first].x > viewport                  if (rects[k].x + rects[k].width - rects[first].x > viewport
1758                                                                     .getWidth())                      .getWidth())
1759                    {                    {
1760                      last = k;                      last = k;
1761                      break;                      break;
1762                    }                    }
1763                }                }
1764            }            }
1765    
1766          for (int j = first; j <= last; j++)          for (int j = first; j <= last; j++)
1767            {            {
1768              if (j != selectedIndex || isScroll)              if (j != selectedIndex || isScroll)
1769                paintTab(g, tabPlacement, rects, j, ir, tr);                paintTab(g, tabPlacement, rects, j, ir, tr);
1770            }            }
1771          currRun = getPreviousTabRun(currRun);          currRun = getPreviousTabRun(currRun);
1772        }        }
1773      if (! isScroll)      if (! isScroll)
1774        paintTab(g, tabPlacement, rects, selectedIndex, ir, tr);        paintTab(g, tabPlacement, rects, selectedIndex, ir, tr);
# Line 1800  public class BasicTabbedPaneUI extends T Line 1800  public class BasicTabbedPaneUI extends T
1800      int h = calcRect.height;      int h = calcRect.height;
1801      if (getRunForTab(tabPane.getTabCount(), tabIndex) == 1)      if (getRunForTab(tabPane.getTabCount(), tabIndex) == 1)
1802        {        {
1803          Insets insets = getTabAreaInsets(tabPlacement);          Insets insets = getTabAreaInsets(tabPlacement);
1804          switch (tabPlacement)          switch (tabPlacement)
1805            {          {
1806            case TOP:          case TOP:
1807              h += insets.bottom;            h += insets.bottom;
1808              break;            break;
1809            case LEFT:          case LEFT:
1810              w += insets.right;            w += insets.right;
1811              break;            break;
1812            case BOTTOM:          case BOTTOM:
1813              y -= insets.top;            y -= insets.top;
1814              h += insets.top;            h += insets.top;
1815              break;            break;
1816            case RIGHT:          case RIGHT:
1817              x -= insets.left;            x -= insets.left;
1818              w += insets.left;            w += insets.left;
1819              break;            break;
1820            }          }
1821        }        }
1822    
1823      layoutLabel(tabPlacement, fm, tabIndex, title, icon, calcRect, iconRect,      layoutLabel(tabPlacement, fm, tabIndex, title, icon, calcRect, iconRect,
# Line 1904  public class BasicTabbedPaneUI extends T Line 1904  public class BasicTabbedPaneUI extends T
1904      View textView = getTextViewForTab(tabIndex);      View textView = getTextViewForTab(tabIndex);
1905      if (textView != null)      if (textView != null)
1906        {        {
1907          textView.paint(g, textRect);          textView.paint(g, textRect);
1908          return;          return;
1909        }        }
1910    
1911      Color fg = tabPane.getForegroundAt(tabIndex);      Color fg = tabPane.getForegroundAt(tabIndex);
# Line 1921  public class BasicTabbedPaneUI extends T Line 1921  public class BasicTabbedPaneUI extends T
1921    
1922      if (tabPane.isEnabledAt(tabIndex))      if (tabPane.isEnabledAt(tabIndex))
1923        {        {
1924          g.setColor(fg);          g.setColor(fg);
1925    
1926          int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);          int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
1927    
1928          if (mnemIndex != -1)          if (mnemIndex != -1)
1929            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
1930                                                         textRect.x,                                                         textRect.x,
1931                                                         textRect.y                                                         textRect.y
1932                                                         + metrics.getAscent());                                                         + metrics.getAscent());
1933          else          else
1934            g.drawString(title, textRect.x, textRect.y + metrics.getAscent());            g.drawString(title, textRect.x, textRect.y + metrics.getAscent());
1935        }        }
1936      else      else
1937        {        {
1938          g.setColor(bg.brighter());          g.setColor(bg.brighter());
1939    
1940          int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);          int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
1941    
1942          if (mnemIndex != -1)          if (mnemIndex != -1)
1943            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
1944                                                         textRect.x, textRect.y);                                                         textRect.x, textRect.y);
1945          else          else
1946            g.drawString(title, textRect.x, textRect.y);            g.drawString(title, textRect.x, textRect.y);
1947    
1948          g.setColor(bg.darker());          g.setColor(bg.darker());
1949          if (mnemIndex != -1)          if (mnemIndex != -1)
1950            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,
1951                                                         textRect.x + 1,                                                         textRect.x + 1,
1952                                                         textRect.y + 1);                                                         textRect.y + 1);
1953          else          else
1954            g.drawString(title, textRect.x + 1, textRect.y + 1);            g.drawString(title, textRect.x + 1, textRect.y + 1);
1955        }        }
1956    
1957      g.setColor(saved_color);      g.setColor(saved_color);
# Line 2037  public class BasicTabbedPaneUI extends T Line 2037  public class BasicTabbedPaneUI extends T
2037    
2038      if (! isSelected || tabPlacement != SwingConstants.TOP)      if (! isSelected || tabPlacement != SwingConstants.TOP)
2039        {        {
2040          g.setColor(shadow);          g.setColor(shadow);
2041          g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);          g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
2042          g.setColor(darkShadow);          g.setColor(darkShadow);
2043          g.drawLine(x, y + h, x + w, y + h);          g.drawLine(x, y + h, x + w, y + h);
2044        }        }
2045    
2046      if (! isSelected || tabPlacement != SwingConstants.LEFT)      if (! isSelected || tabPlacement != SwingConstants.LEFT)
2047        {        {
2048          g.setColor(darkShadow);          g.setColor(darkShadow);
2049          g.drawLine(x + w, y, x + w, y + h);          g.drawLine(x + w, y, x + w, y + h);
2050          g.setColor(shadow);          g.setColor(shadow);
2051          g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);          g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
2052        }        }
2053    
2054      if (! isSelected || tabPlacement != SwingConstants.RIGHT)      if (! isSelected || tabPlacement != SwingConstants.RIGHT)
2055        {        {
2056          g.setColor(lightHighlight);          g.setColor(lightHighlight);
2057          g.drawLine(x, y, x, y + h);          g.drawLine(x, y, x, y + h);
2058        }        }
2059    
2060      if (! isSelected || tabPlacement != SwingConstants.BOTTOM)      if (! isSelected || tabPlacement != SwingConstants.BOTTOM)
2061        {        {
2062          g.setColor(lightHighlight);          g.setColor(lightHighlight);
2063          g.drawLine(x, y, x + w, y);          g.drawLine(x, y, x + w, y);
2064        }        }
2065    
2066      g.setColor(saved);      g.setColor(saved);
# Line 2087  public class BasicTabbedPaneUI extends T Line 2087  public class BasicTabbedPaneUI extends T
2087        g.setColor(Color.LIGHT_GRAY);        g.setColor(Color.LIGHT_GRAY);
2088      else      else
2089        {        {
2090          Color bg = tabPane.getBackgroundAt(tabIndex);          Color bg = tabPane.getBackgroundAt(tabIndex);
2091          if (bg == null)          if (bg == null)
2092            bg = Color.GRAY;            bg = Color.GRAY;
2093          g.setColor(bg);          g.setColor(bg);
2094        }        }
2095    
2096      g.fillRect(x, y, w, h);      g.fillRect(x, y, w, h);
# Line 2144  public class BasicTabbedPaneUI extends T Line 2144  public class BasicTabbedPaneUI extends T
2144    
2145      if (tabPlacement == SwingConstants.TOP)      if (tabPlacement == SwingConstants.TOP)
2146        {        {
2147          if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)          if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
2148            {            {
2149              Point p = findPointForIndex(currentScrollLocation);              Point p = findPointForIndex(currentScrollLocation);
2150              diff = p.x;              diff = p.x;
2151            }            }
2152    
2153          g.drawLine(x, y, startgap - diff, y);          g.drawLine(x, y, startgap - diff, y);
2154          g.drawLine(endgap - diff, y, x + w, y);          g.drawLine(endgap - diff, y, x + w, y);
2155        }        }
2156      else      else
2157        g.drawLine(x, y, x + w, y);        g.drawLine(x, y, x + w, y);
# Line 2184  public class BasicTabbedPaneUI extends T Line 2184  public class BasicTabbedPaneUI extends T
2184    
2185      if (tabPlacement == SwingConstants.LEFT)      if (tabPlacement == SwingConstants.LEFT)
2186        {        {
2187          if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)          if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
2188            {            {
2189              Point p = findPointForIndex(currentScrollLocation);              Point p = findPointForIndex(currentScrollLocation);
2190              diff = p.y;              diff = p.y;
2191            }            }
2192    
2193          g.drawLine(x, y, x, startgap - diff);          g.drawLine(x, y, x, startgap - diff);
2194          g.drawLine(x, endgap - diff, x, y + h);          g.drawLine(x, endgap - diff, x, y + h);
2195        }        }
2196      else      else
2197        g.drawLine(x, y, x, y + h);        g.drawLine(x, y, x, y + h);
# Line 2223  public class BasicTabbedPaneUI extends T Line 2223  public class BasicTabbedPaneUI extends T
2223    
2224      if (tabPlacement == SwingConstants.BOTTOM)      if (tabPlacement == SwingConstants.BOTTOM)
2225        {        {
2226          if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)          if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
2227            {            {
2228              Point p = findPointForIndex(currentScrollLocation);              Point p = findPointForIndex(currentScrollLocation);
2229              diff = p.x;              diff = p.x;
2230            }            }
2231    
2232          g.setColor(shadow);          g.setColor(shadow);
2233          g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1);          g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1);
2234          g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1);          g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1);
2235    
2236          g.setColor(darkShadow);          g.setColor(darkShadow);
2237          g.drawLine(x, y + h, startgap - diff, y + h);          g.drawLine(x, y + h, startgap - diff, y + h);
2238          g.drawLine(endgap - diff, y + h, x + w, y + h);          g.drawLine(endgap - diff, y + h, x + w, y + h);
2239        }        }
2240      else      else
2241        {        {
2242          g.setColor(shadow);          g.setColor(shadow);
2243          g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);          g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
2244          g.setColor(darkShadow);          g.setColor(darkShadow);
2245          g.drawLine(x, y + h, x + w, y + h);          g.drawLine(x, y + h, x + w, y + h);
2246        }        }
2247    
2248      g.setColor(saved);      g.setColor(saved);
# Line 2271  public class BasicTabbedPaneUI extends T Line 2271  public class BasicTabbedPaneUI extends T
2271    
2272      if (tabPlacement == SwingConstants.RIGHT)      if (tabPlacement == SwingConstants.RIGHT)
2273        {        {
2274          if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)          if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
2275            {            {
2276              Point p = findPointForIndex(currentScrollLocation);              Point p = findPointForIndex(currentScrollLocation);
2277              diff = p.y;              diff = p.y;
2278            }            }
2279    
2280          g.setColor(shadow);          g.setColor(shadow);
2281          g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff);          g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff);
2282          g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1);          g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1);
2283    
2284          g.setColor(darkShadow);          g.setColor(darkShadow);
2285          g.drawLine(x + w, y, x + w, startgap - diff);          g.drawLine(x + w, y, x + w, startgap - diff);
2286          g.drawLine(x + w, endgap - diff, x + w, y + h);          g.drawLine(x + w, endgap - diff, x + w, y + h);
2287        }        }
2288      else      else
2289        {        {
2290          g.setColor(shadow);          g.setColor(shadow);
2291          g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);          g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
2292          g.setColor(darkShadow);          g.setColor(darkShadow);
2293          g.drawLine(x + w, y, x + w, y + h);          g.drawLine(x + w, y, x + w, y + h);
2294        }        }
2295    
2296      g.setColor(saved);      g.setColor(saved);
# Line 2337  public class BasicTabbedPaneUI extends T Line 2337  public class BasicTabbedPaneUI extends T
2337      int currRun = 1;      int currRun = 1;
2338      for (int i = 0; i < runCount; i++)      for (int i = 0; i < runCount; i++)
2339        {        {
2340          int first = lastTabInRun(tabCount, getPreviousTabRun(currRun)) + 1;          int first = lastTabInRun(tabCount, getPreviousTabRun(currRun)) + 1;
2341          if (first == tabCount)          if (first == tabCount)
2342            first = 0;            first = 0;
2343          int last = lastTabInRun(tabCount, currRun);          int last = lastTabInRun(tabCount, currRun);
2344          for (int j = first; j <= last; j++)          for (int j = first; j <= last; j++)
2345            {            {
2346              if (getTabBounds(pane, j).contains(p))              if (getTabBounds(pane, j).contains(p))
2347                return j;                return j;
2348            }            }
2349          currRun = getNextTabRun(currRun);          currRun = getNextTabRun(currRun);
2350        }        }
2351      return -1;      return -1;
2352    }    }
# Line 2400  public class BasicTabbedPaneUI extends T Line 2400  public class BasicTabbedPaneUI extends T
2400        return;        return;
2401      else      else
2402        {        {
2403          int numToCopy = Math.min(tabCount, rects.length);          int numToCopy = Math.min(tabCount, rects.length);
2404          Rectangle[] tmp = new Rectangle[tabCount];          Rectangle[] tmp = new Rectangle[tabCount];
2405          System.arraycopy(rects, 0, tmp, 0, numToCopy);          System.arraycopy(rects, 0, tmp, 0, numToCopy);
2406          rects = tmp;          rects = tmp;
2407        }        }
2408    }    }
2409    
# Line 2418  public class BasicTabbedPaneUI extends T Line 2418  public class BasicTabbedPaneUI extends T
2418        tabRuns = new int[10];        tabRuns = new int[10];
2419      else      else
2420        {        {
2421          int[] newRuns = new int[tabRuns.length + 10];          int[] newRuns = new int[tabRuns.length + 10];
2422          System.arraycopy(tabRuns, 0, newRuns, 0, tabRuns.length);          System.arraycopy(tabRuns, 0, newRuns, 0, tabRuns.length);
2423          tabRuns = newRuns;          tabRuns = newRuns;
2424        }        }
2425    }    }
2426    
# Line 2438  public class BasicTabbedPaneUI extends T Line 2438  public class BasicTabbedPaneUI extends T
2438        return 1;        return 1;
2439      for (int i = 0; i < runCount; i++)      for (int i = 0; i < runCount; i++)
2440        {        {
2441          int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1;          int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1;
2442          if (first == tabCount)          if (first == tabCount)
2443            first = 0;            first = 0;
2444          int last = lastTabInRun(tabCount, i);          int last = lastTabInRun(tabCount, i);
2445          if (last >= tabIndex && first <= tabIndex)          if (last >= tabIndex && first <= tabIndex)
2446            return i;            return i;
2447        }        }
2448      return -1;      return -1;
2449    }    }
# Line 2560  public class BasicTabbedPaneUI extends T Line 2560  public class BasicTabbedPaneUI extends T
2560      Icon icon = getIconForTab(tabIndex);      Icon icon = getIconForTab(tabIndex);
2561      Insets insets = getTabInsets(tabPlacement, tabIndex);      Insets insets = getTabInsets(tabPlacement, tabIndex);
2562    
2563        int height = 0;
2564      if (icon != null)      if (icon != null)
2565        {        {
2566          Rectangle vr = new Rectangle();          Rectangle vr = new Rectangle();
2567          Rectangle ir = new Rectangle();          Rectangle ir = new Rectangle();
2568          Rectangle tr = new Rectangle();          Rectangle tr = new Rectangle();
2569          layoutLabel(tabPlacement, getFontMetrics(), tabIndex,          layoutLabel(tabPlacement, getFontMetrics(), tabIndex,
2570                      tabPane.getTitleAt(tabIndex), icon, vr, ir, tr,                      tabPane.getTitleAt(tabIndex), icon, vr, ir, tr,
2571                      tabIndex == tabPane.getSelectedIndex());                      tabIndex == tabPane.getSelectedIndex());
2572          calcRect = tr.union(ir);          height = tr.union(ir).height;
2573        }        }
2574      else      else
2575        calcRect.height = fontHeight;        height = fontHeight;
2576    
2577      calcRect.height += insets.top + insets.bottom;      height += insets.top + insets.bottom;
2578      return calcRect.height;      return height;
2579    }    }
2580    
2581    /**    /**
# Line 2614  public class BasicTabbedPaneUI extends T Line 2615  public class BasicTabbedPaneUI extends T
2615      Icon icon = getIconForTab(tabIndex);      Icon icon = getIconForTab(tabIndex);
2616      Insets insets = getTabInsets(tabPlacement, tabIndex);      Insets insets = getTabInsets(tabPlacement, tabIndex);
2617    
2618        int width = 0;
2619      if (icon != null)      if (icon != null)
2620        {        {
2621          Rectangle vr = new Rectangle();          Rectangle vr = new Rectangle();
2622          Rectangle ir = new Rectangle();          Rectangle ir = new Rectangle();
2623          Rectangle tr = new Rectangle();          Rectangle tr = new Rectangle();
2624          layoutLabel(tabPlacement, getFontMetrics(), tabIndex,          layoutLabel(tabPlacement, getFontMetrics(), tabIndex,
2625                      tabPane.getTitleAt(tabIndex), icon, vr, ir, tr,                      tabPane.getTitleAt(tabIndex), icon, vr, ir, tr,
2626                      tabIndex == tabPane.getSelectedIndex());                      tabIndex == tabPane.getSelectedIndex());
2627          calcRect = tr.union(ir);          width = tr.union(ir).width;
2628        }        }
2629      else      else
2630        calcRect.width = metrics.stringWidth(tabPane.getTitleAt(tabIndex));        width = metrics.stringWidth(tabPane.getTitleAt(tabIndex));
2631    
2632      calcRect.width += insets.left + insets.right;      width += insets.left + insets.right;
2633      return calcRect.width;      return width;
2634    }    }
2635    
2636    /**    /**
# Line 2775  public class BasicTabbedPaneUI extends T Line 2777  public class BasicTabbedPaneUI extends T
2777      if (tabPlacement == SwingConstants.TOP      if (tabPlacement == SwingConstants.TOP
2778          || tabPlacement == SwingConstants.BOTTOM)          || tabPlacement == SwingConstants.BOTTOM)
2779        {        {
2780          if (direction == SwingConstants.WEST)          if (direction == SwingConstants.WEST)
2781            selectPreviousTabInRun(tabPane.getSelectedIndex());            selectPreviousTabInRun(tabPane.getSelectedIndex());
2782          else if (direction == SwingConstants.EAST)          else if (direction == SwingConstants.EAST)
2783            selectNextTabInRun(tabPane.getSelectedIndex());            selectNextTabInRun(tabPane.getSelectedIndex());
2784    
2785          else          else
2786            {            {
2787              int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(),              int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(),
2788                                           tabPane.getSelectedIndex(),                                           tabPane.getSelectedIndex(),
2789                                           (tabPlacement == SwingConstants.RIGHT)                                           (tabPlacement == SwingConstants.RIGHT)
2790                                           ? true : false);                                           ? true : false);
2791              selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(),              selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(),
2792                                   offset);                                   offset);
2793            }            }
2794        }        }
2795      if (tabPlacement == SwingConstants.LEFT      if (tabPlacement == SwingConstants.LEFT
2796          || tabPlacement == SwingConstants.RIGHT)          || tabPlacement == SwingConstants.RIGHT)
2797        {        {
2798          if (direction == SwingConstants.NORTH)          if (direction == SwingConstants.NORTH)
2799            selectPreviousTabInRun(tabPane.getSelectedIndex());            selectPreviousTabInRun(tabPane.getSelectedIndex());
2800          else if (direction == SwingConstants.SOUTH)          else if (direction == SwingConstants.SOUTH)
2801            selectNextTabInRun(tabPane.getSelectedIndex());            selectNextTabInRun(tabPane.getSelectedIndex());
2802          else          else
2803            {            {
2804              int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(),              int offset = getTabRunOffset(tabPlacement, tabPane.getTabCount(),
2805                                           tabPane.getSelectedIndex(),                                           tabPane.getSelectedIndex(),
2806                                           (tabPlacement == SwingConstants.RIGHT)                                           (tabPlacement == SwingConstants.RIGHT)
2807                                           ? true : false);                                           ? true : false);
2808              selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(),              selectAdjacentRunTab(tabPlacement, tabPane.getSelectedIndex(),
2809                                   offset);                                   offset);
2810            }            }
2811        }        }
2812    }    }
2813    
# Line 2869  public class BasicTabbedPaneUI extends T Line 2871  public class BasicTabbedPaneUI extends T
2871      int y = rects[tabIndex].y + rects[tabIndex].height / 2;      int y = rects[tabIndex].y + rects[tabIndex].height / 2;
2872    
2873      switch (tabPlacement)      switch (tabPlacement)
2874        {      {
2875        case SwingConstants.TOP:      case SwingConstants.TOP:
2876        case SwingConstants.BOTTOM:      case SwingConstants.BOTTOM:
2877          y += offset;        y += offset;
2878          break;        break;
2879        case SwingConstants.RIGHT:      case SwingConstants.RIGHT:
2880        case SwingConstants.LEFT:      case SwingConstants.LEFT:
2881          x += offset;        x += offset;
2882          break;        break;
2883        }      }
2884    
2885      int index = tabForCoordinate(tabPane, x, y);      int index = tabForCoordinate(tabPane, x, y);
2886      if (index != -1)      if (index != -1)
# Line 3042  public class BasicTabbedPaneUI extends T Line 3044  public class BasicTabbedPaneUI extends T
3044      // Sun's version will happily throw an NPE if params are null,      // Sun's version will happily throw an NPE if params are null,
3045      // so I won't check it either.      // so I won't check it either.
3046      switch (targetPlacement)      switch (targetPlacement)
3047        {      {
3048        case SwingConstants.TOP:      case SwingConstants.TOP:
3049          targetInsets.top = topInsets.top;        targetInsets.top = topInsets.top;
3050          targetInsets.left = topInsets.left;        targetInsets.left = topInsets.left;
3051          targetInsets.right = topInsets.right;        targetInsets.right = topInsets.right;
3052          targetInsets.bottom = topInsets.bottom;        targetInsets.bottom = topInsets.bottom;
3053          break;        break;
3054        case SwingConstants.LEFT:      case SwingConstants.LEFT:
3055          targetInsets.left = topInsets.top;        targetInsets.left = topInsets.top;
3056          targetInsets.top = topInsets.left;        targetInsets.top = topInsets.left;
3057          targetInsets.right = topInsets.bottom;        targetInsets.right = topInsets.bottom;
3058          targetInsets.bottom = topInsets.right;        targetInsets.bottom = topInsets.right;
3059          break;        break;
3060        case SwingConstants.BOTTOM:      case SwingConstants.BOTTOM:
3061          targetInsets.top = topInsets.bottom;        targetInsets.top = topInsets.bottom;
3062          targetInsets.bottom = topInsets.top;        targetInsets.bottom = topInsets.top;
3063          targetInsets.left = topInsets.left;        targetInsets.left = topInsets.left;
3064          targetInsets.right = topInsets.right;        targetInsets.right = topInsets.right;
3065          break;        break;
3066        case SwingConstants.RIGHT:      case SwingConstants.RIGHT:
3067          targetInsets.top = topInsets.left;        targetInsets.top = topInsets.left;
3068          targetInsets.left = topInsets.bottom;        targetInsets.left = topInsets.bottom;
3069          targetInsets.bottom = topInsets.right;        targetInsets.bottom = topInsets.right;
3070          targetInsets.right = topInsets.top;        targetInsets.right = topInsets.top;
3071          break;        break;
3072        }      }
3073    }    }
3074  }  }

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26