Index: javax/swing/plaf/metal/MetalLookAndFeel.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,v retrieving revision 1.71 diff -u -r1.71 MetalLookAndFeel.java --- javax/swing/plaf/metal/MetalLookAndFeel.java 16 Nov 2005 20:33:06 -0000 1.71 +++ javax/swing/plaf/metal/MetalLookAndFeel.java 23 Nov 2005 19:38:28 -0000 @@ -40,7 +40,6 @@ import java.awt.Color; import java.awt.Font; -import java.awt.Insets; import javax.swing.LookAndFeel; import javax.swing.UIDefaults; @@ -902,9 +901,11 @@ "Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10), "Menu.acceleratorForeground", getAcceleratorForeground(), "Menu.acceleratorSelectionForeground", getAcceleratorSelectedForeground(), + "Menu.arrowIcon", MetalIconFactory.getMenuArrowIcon(), "Menu.background", getMenuBackground(), "Menu.border", new MetalBorders.MenuItemBorder(), "Menu.borderPainted", Boolean.TRUE, + "Menu.checkIcon", MetalIconFactory.getMenuItemCheckIcon(), "Menu.disabledForeground", getMenuDisabledForeground(), "Menu.font", getControlTextFont(), "Menu.foreground", getMenuForeground(), @@ -921,6 +922,7 @@ "MenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10), "MenuItem.acceleratorForeground", getAcceleratorForeground(), "MenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(), + "MenuItem.arrowIcon", MetalIconFactory.getMenuItemArrowIcon(), "MenuItem.background", getMenuBackground(), "MenuItem.border", new MetalBorders.MenuItemBorder(), "MenuItem.disabledForeground", getMenuDisabledForeground(), Index: javax/swing/plaf/metal/MetalTabbedPaneUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java,v retrieving revision 1.14 diff -u -r1.14 MetalTabbedPaneUI.java --- javax/swing/plaf/metal/MetalTabbedPaneUI.java 22 Nov 2005 21:10:00 -0000 1.14 +++ javax/swing/plaf/metal/MetalTabbedPaneUI.java 23 Nov 2005 19:38:28 -0000 @@ -123,6 +123,9 @@ */ protected Color tabAreaBackground; + /** The graphics to draw the highlight below the tab. */ + private Graphics hg; + /** * Constructs a new instance of MetalTabbedPaneUI. */ @@ -198,6 +201,16 @@ protected void paintTopTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) { + int currentRun = getRunForTab(tabPane.getTabCount(), tabIndex); + if (shouldFillGap(currentRun, tabIndex, x, y)) + { + g.translate(x, y); + g.setColor(getColorForGap(currentRun, x, y)); + g.fillRect(1, 0, 5, 3); + g.fillRect(1, 3, 2, 2); + g.translate(-x, -y); + } + if (isSelected) { g.setColor(MetalLookAndFeel.getControlHighlight()); @@ -290,6 +303,16 @@ protected void paintBottomTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) { + int currentRun = getRunForTab(tabPane.getTabCount(), tabIndex); + if (shouldFillGap(currentRun, tabIndex, x, y)) + { + g.translate(x, y); + g.setColor(getColorForGap(currentRun, x, y)); + g.fillRect(1, h - 5, 3, 5); + g.fillRect(4, h - 2, 2, 2); + g.translate(-x, -y); + } + if (isSelected) { g.setColor(MetalLookAndFeel.getControlHighlight()); @@ -354,6 +377,8 @@ else throw new AssertionError("Unrecognised 'tabPlacement' argument."); g.fillPolygon(px, py, 5); + hg = g; + paintHighlightBelowTab(); } /** @@ -397,19 +422,14 @@ */ protected Color getColorForGap(int currentRun, int x, int y) { + int index = tabForCoordinate(tabPane, x, y); + int selected = tabPane.getSelectedIndex(); + if (selected == index) + return selectColor; return tabAreaBackground; } /** - * Paints the highlight below the tab, if there is one. - */ - protected void paintHighlightBelowTab() - { - // Nothing to do here, no highlight below the tab as far - // as I can see. - } - - /** * Returns true if the gap should be filled in. * * @param currentRun - The current run @@ -419,10 +439,38 @@ * * @return true if the gap at the current run should be filled */ - protected boolean shouldFillGap(int currentRun, int tabIndex, - int x, int y) + protected boolean shouldFillGap(int currentRun, int tabIndex, int x, int y) { - return true; + // As far as I can tell, the gap is never filled in. + return false; + } + + /** + * Paints the highlight below the tab, if there is one. + */ + protected void paintHighlightBelowTab() + { + int selected = tabPane.getSelectedIndex(); + int tabPlacement = tabPane.getTabPlacement(); + Rectangle bounds = getTabBounds(tabPane, selected); + + hg.setColor(selectColor); + int x = bounds.x; + int y = bounds.y; + int w = bounds.width; + int h = bounds.height; + + if (tabPlacement == TOP) + hg.fillRect(x, y + h - 2, w, 30); + else if (tabPlacement == LEFT) + hg.fillRect(x + w - 1, y, 20, h); + else if (tabPlacement == BOTTOM) + hg.fillRect(x, y - h + 2, w, 30); + else if (tabPlacement == RIGHT) + hg.fillRect(x - 18, y, 20, h); + else + throw new AssertionError("Unrecognised 'tabPlacement' argument."); + hg = null; } /** @@ -438,190 +486,5 @@ { // false because tab runs are not rotated in the MetalLookAndFeel return false; - } - - /** - * This method returns the max tab height. - * - * @param tabPlacement The JTabbedPane's tab placement. - * - * @return The maximum tab height. - */ - protected int calculateMaxTabHeight(int tabPlacement) - { - return super.calculateMaxTabHeight(tabPlacement); - } - - /** - * This method returns how much the label for the tab should shift in the X - * direction. - * - * @param tabPlacement The JTabbedPane's tab placement. - * @param tabIndex The tab index being painted. - * @param isSelected Whether this tab is selected. - * - * @return The amount the label should shift by in the X direction. - */ - protected int getTabLabelShiftX(int tabPlacement, int tabIndex, - boolean isSelected) - { - // No reason to shift. - return 0; - } - - /** - * This method returns how much the label for the tab should shift in the Y - * direction. - * - * @param tabPlacement The JTabbedPane's tab placement. - * @param tabIndex The tab index being painted. - * @param isSelected Whether this tab is selected. - * - * @return The amount the label should shift by in the Y direction. - */ - protected int getTabLabelShiftY(int tabPlacement, int tabIndex, - boolean isSelected) - { - // No reason to shift. - return 0; - } - - /** - * This method returns the tab run overlay. - * - * @param tabPlacement The JTabbedPane's tab placement. - * - * @return The tab run overlay. - */ - protected int getTabRunOverlay(int tabPlacement) - { - tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay"); - return tabRunOverlay; - } - - /** - * This method paints the JTabbedPane. - * - * @param g The Graphics object to paint with. - * @param c The JComponent to paint. - */ - public void paint(Graphics g, JComponent c) - { - super.paint(g, c); - } - - /** - * This method paints the bottom edge of the content border. - * - * @param g The Graphics object to paint with. - * @param tabPlacement The JTabbedPane's tab placement. - * @param selectedIndex The selected tab index. - * @param x The x coordinate for the content area. - * @param y The y coordinate for the content area. - * @param w The width of the content area. - * @param h The height of the content area. - */ - protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, - int selectedIndex, int x, int y, - int w, int h) - { - super.paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, - x, y, w, h); - } - - /** - * This method paints the left edge of the content border. - * - * @param g The Graphics object to paint with. - * @param tabPlacement The JTabbedPane's tab placement. - * @param selectedIndex The selected tab index. - * @param x The x coordinate for the content area. - * @param y The y coordinate for the content area. - * @param w The width of the content area. - * @param h The height of the content area. - */ - protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, - int selectedIndex, int x, int y, - int w, int h) - { - super.paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, - x, y, w, h); - } - - /** - * This method paints the right edge of the content border. - * - * @param g The Graphics object to paint with. - * @param tabPlacement The JTabbedPane's tab placement. - * @param selectedIndex The selected tab index. - * @param x The x coordinate for the content area. - * @param y The y coordinate for the content area. - * @param w The width of the content area. - * @param h The height of the content area. - */ - protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, - int selectedIndex, int x, int y, - int w, int h) - { - super.paintContentBorderRightEdge(g, tabPlacement, selectedIndex, - x, y, w, h); - } - - /** - * This method paints the top edge of the content border. - * - * @param g The Graphics object to paint with. - * @param tabPlacement The JTabbedPane's tab placement. - * @param selectedIndex The selected tab index. - * @param x The x coordinate for the content area. - * @param y The y coordinate for the content area. - * @param w The width of the content area. - * @param h The height of the content area. - */ - protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, - int selectedIndex, int x, int y, - int w, int h) - { - super.paintContentBorderTopEdge(g, tabPlacement, selectedIndex, - x, y, w, h); - } - - /** - * This method paints the focus rectangle around the selected tab. - * - * @param g The Graphics object to paint with. - * @param tabPlacement The JTabbedPane's tab placement. - * @param rects The array of rectangles keeping track of size and position. - * @param tabIndex The tab index. - * @param iconRect The icon bounds. - * @param textRect The text bounds. - * @param isSelected Whether this tab is selected. - */ - protected void paintFocusIndicator(Graphics g, int tabPlacement, - Rectangle[] rects, int tabIndex, - Rectangle iconRect, Rectangle textRect, - boolean isSelected) - { - super.paintFocusIndicator(g, tabPlacement, rects, tabIndex, - iconRect, textRect, isSelected); - } - - /** - * Notifies this UI delegate that it's time to paint the specified - * component. This method is invoked by JComponent when the specified - * component is being painted. By default this method will fill the - * specified component with its background color (if its opaque property - * is true) and then immediately call paint. In general this method need - * not be overridden by subclasses; all look-and-feel rendering code should - * reside in the paint method. - * - * @param g - the Graphics context in which to paint - * @param c - the component being painted; this argument - * is often ignored, but might be used if the UI object is - * stateless and shared by multiple components - */ - public void update(Graphics g, JComponent c) - { - super.update(g, c); } }