Hi, yet another patch related to the tabbed panes' UI classes. getTabBounds() was not spec conform in the way that it did not calculated the scroll offset in. By not doing that subclasses could not properly find out whether a tab may be out of bounds.
By fixing that tabs painted in the MetalTheme now properly display the broken line when a tab adjacent to the content area is selected (which is always the case in scrolling tab layout mode). Another small fix for MetalTabbedPaneUI corrects an argument value. Now a line of the left edge is painted completely vertical. the ChangeLog: 2006-08-17 Robert Schuster <[EMAIL PROTECTED]> * javax/swing/plaf/basic/BasicTabbedPaneUI.java: (getTabBounds(JTabbedPane, int)): Added code to shift rectangle by current scroll offset, added method documention. (getTabBounds(int, Rectangle)): Added method documentation. * javax/swing/plaf/metal/MetalTabbedPaneUI.java: (paintContentBorderLeftEdge): Changed y to 1. cya Robert
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v retrieving revision 1.52 diff -u -r1.52 BasicTabbedPaneUI.java --- javax/swing/plaf/basic/BasicTabbedPaneUI.java 16 Aug 2006 22:55:02 -0000 1.52 +++ javax/swing/plaf/basic/BasicTabbedPaneUI.java 16 Aug 2006 23:37:32 -0000 @@ -3111,8 +3111,13 @@ } /** - * This method returns the tab bounds for the given index. - * + * <p>This method returns the bounds of a tab for the given index + * and shifts it by the current scrolling offset if the tabbed + * pane is in scrolling tab layout mode.</p> + * + * <p>Subclassses should retrievs a tab's bounds by this method + * if they want to find out whether the tab is currently visible.</p> + * * @param pane The JTabbedPane. * @param i The index to look for. * @@ -3123,6 +3128,26 @@ // Need to re-layout container if tab does not exist. if (i >= rects.length) layoutManager.layoutContainer(pane); + + // Properly shift coordinates if scrolling has taken + // place. + if (pane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) + { + Rectangle r = new Rectangle(rects[i]); + + switch(pane.getTabPlacement()) + { + case SwingConstants.TOP: + case SwingConstants.BOTTOM: + r.x -= currentScrollOffset; + break; + default: + r.y -= currentScrollOffset; + } + + return r; + } + return rects[i]; } @@ -3171,7 +3196,10 @@ } /** - * This method returns the tab bounds in the given rectangle. + * <p>This method returns the tab bounds in the given rectangle.</p> + * + * <p>The returned rectangle will be shifted by the current scroll + * offset if the tabbed pane is in scrolling tab layout mode.</p>. * * @param tabIndex The index to get bounds for. * @param dest The rectangle to store bounds in. Index: javax/swing/plaf/metal/MetalTabbedPaneUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java,v retrieving revision 1.21 diff -u -r1.21 MetalTabbedPaneUI.java --- javax/swing/plaf/metal/MetalTabbedPaneUI.java 27 Jul 2006 01:28:41 -0000 1.21 +++ javax/swing/plaf/metal/MetalTabbedPaneUI.java 16 Aug 2006 23:37:32 -0000 @@ -1159,7 +1159,7 @@ g.drawLine(x + 1, y + 1, x + 1, rect.y + 1); if (rect.y + rect.height < y + h - 2) { - g.drawLine(x + y, rect.y + rect.height + 1, x + 1, y + h + 2); + g.drawLine(x + 1, rect.y + rect.height + 1, x + 1, y + h + 2); } } }
signature.asc
Description: OpenPGP digital signature