1 /* |
1 /* |
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
38 import java.awt.Frame; |
38 import java.awt.Frame; |
39 import java.awt.Graphics; |
39 import java.awt.Graphics; |
40 import java.awt.Window; |
40 import java.awt.Window; |
41 |
41 |
42 import sun.swing.StringUIClientPropertyKey; |
42 import sun.swing.StringUIClientPropertyKey; |
|
43 import sun.swing.SwingUtilities2; |
43 |
44 |
44 |
45 |
45 /** |
46 /** |
46 * Factory object that can vend Borders appropriate for the metal L & F. |
47 * Factory object that can vend Borders appropriate for the metal L & F. |
47 * @author Steve Wilson |
48 * @author Steve Wilson |
557 * The border insets. |
558 * The border insets. |
558 */ |
559 */ |
559 protected static Insets borderInsets = new Insets( 1, 0, 1, 0 ); |
560 protected static Insets borderInsets = new Insets( 1, 0, 1, 0 ); |
560 |
561 |
561 public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) { |
562 public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) { |
562 g.translate( x, y ); |
563 g.translate(x, y); |
563 |
564 |
564 if (MetalLookAndFeel.usingOcean()) { |
565 if (MetalLookAndFeel.usingOcean()) { |
565 // Only paint a border if we're not next to a horizontal |
566 // Only paint a border if we're not next to a horizontal toolbar |
566 // toolbar |
567 if (c instanceof JMenuBar |
567 if ((c instanceof JMenuBar) && !MetalToolBarUI.doesMenuBarBorderToolBar((JMenuBar)c)) { |
568 && !MetalToolBarUI.doesMenuBarBorderToolBar((JMenuBar)c)) { |
568 g.setColor(MetalLookAndFeel.getControl()); |
569 g.setColor(MetalLookAndFeel.getControl()); |
569 g.drawLine(0, h - 2, w, h - 2); |
570 SwingUtilities2.drawHLine(g, 0, w - 1, h - 2); |
570 g.setColor(UIManager.getColor("MenuBar.borderColor")); |
571 g.setColor(UIManager.getColor("MenuBar.borderColor")); |
571 g.drawLine(0, h - 1, w, h - 1); |
572 SwingUtilities2.drawHLine(g, 0, w - 1, h - 1); |
572 } |
573 } |
573 } |
574 } else { |
574 else { |
575 g.setColor(MetalLookAndFeel.getControlShadow()); |
575 g.setColor( MetalLookAndFeel.getControlShadow() ); |
576 SwingUtilities2.drawHLine(g, 0, w - 1, h - 1); |
576 g.drawLine( 0, h-1, w, h-1 ); |
577 } |
577 } |
578 g.translate(-x, -y); |
578 |
|
579 g.translate( -x, -y ); |
|
580 |
|
581 } |
579 } |
582 |
580 |
583 public Insets getBorderInsets(Component c, Insets newInsets) { |
581 public Insets getBorderInsets(Component c, Insets newInsets) { |
584 if (MetalLookAndFeel.usingOcean()) { |
582 if (MetalLookAndFeel.usingOcean()) { |
585 newInsets.set(0, 0, 2, 0); |
583 newInsets.set(0, 0, 2, 0); |