KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > metal > MetalBorders


1 /*
2  * @(#)MetalBorders.java 1.39 04/04/16
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.plaf.metal;
9
10 import javax.swing.*;
11 import javax.swing.border.*;
12 import javax.swing.plaf.*;
13 import javax.swing.plaf.basic.BasicBorders JavaDoc;
14 import javax.swing.text.JTextComponent JavaDoc;
15
16 import java.awt.Component JavaDoc;
17 import java.awt.Insets JavaDoc;
18 import java.awt.Dimension JavaDoc;
19 import java.awt.Rectangle JavaDoc;
20 import java.awt.Color JavaDoc;
21 import java.awt.Dialog JavaDoc;
22 import java.awt.Frame JavaDoc;
23 import java.awt.Graphics JavaDoc;
24 import java.awt.Window JavaDoc;
25 import java.io.Serializable JavaDoc;
26
27
28 /**
29  * Factory object that can vend Borders appropriate for the metal L & F.
30  * @author Steve Wilson
31  * @version 1.39 04/16/04
32  */

33
34 public class MetalBorders {
35
36     /**
37      * Client property indicating the button shouldn't provide a rollover
38      * indicator. Only used with the Ocean theme.
39      */

40     static Object JavaDoc NO_BUTTON_ROLLOVER = new StringBuffer JavaDoc("NoButtonRollover");
41
42
43     public static class Flush3DBorder extends AbstractBorder implements UIResource{
44
45         private static final Insets JavaDoc insets = new Insets JavaDoc(2, 2, 2, 2);
46
47         public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y,
48               int w, int h) {
49             if (c.isEnabled()) {
50                 MetalUtils.drawFlush3DBorder(g, x, y, w, h);
51             } else {
52                 MetalUtils.drawDisabledBorder(g, x, y, w, h);
53             }
54         }
55         public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
56             return insets;
57         }
58         public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets) {
59         newInsets.top = insets.top;
60         newInsets.left = insets.left;
61         newInsets.bottom = insets.bottom;
62         newInsets.right = insets.right;
63         return newInsets;
64     }
65     }
66
67     public static class ButtonBorder extends AbstractBorder implements UIResource {
68
69         protected static Insets JavaDoc borderInsets = new Insets JavaDoc( 3, 3, 3, 3 );
70
71         public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y, int w, int h) {
72             if (MetalLookAndFeel.usingOcean()) {
73                 paintOceanBorder(c, g, x, y, w, h);
74                 return;
75             }
76             AbstractButton button = (AbstractButton)c;
77         ButtonModel model = button.getModel();
78
79         if ( model.isEnabled() ) {
80                 boolean isPressed = model.isPressed() && model.isArmed();
81                 boolean isDefault = (button instanceof JButton && ((JButton)button).isDefaultButton());
82
83             if (isPressed && isDefault) {
84                     MetalUtils.drawDefaultButtonPressedBorder(g, x, y, w, h);
85                 } else if (isPressed) {
86                     MetalUtils.drawPressed3DBorder( g, x, y, w, h );
87             } else if (isDefault) {
88                     MetalUtils.drawDefaultButtonBorder( g, x, y, w, h, false);
89                 } else {
90                     MetalUtils.drawButtonBorder( g, x, y, w, h, false);
91             }
92         } else { // disabled state
93
MetalUtils.drawDisabledBorder( g, x, y, w-1, h-1 );
94         }
95         }
96
97         private void paintOceanBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y,
98                                       int w, int h) {
99             AbstractButton button = (AbstractButton)c;
100         ButtonModel model = ((AbstractButton)c).getModel();
101
102             g.translate(x, y);
103             if (MetalUtils.isToolBarButton(button)) {
104                 if (model.isEnabled()) {
105                     if (model.isPressed()) {
106                         g.setColor(MetalLookAndFeel.getWhite());
107                         g.fillRect(1, h - 1, w - 1, 1);
108                         g.fillRect(w - 1, 1, 1, h - 1);
109                         g.setColor(MetalLookAndFeel.getControlDarkShadow());
110                         g.drawRect(0, 0, w - 2, h - 2);
111                         g.fillRect(1, 1, w - 3, 1);
112                     }
113                     else if (model.isSelected() || model.isRollover()) {
114                         g.setColor(MetalLookAndFeel.getWhite());
115                         g.fillRect(1, h - 1, w - 1, 1);
116                         g.fillRect(w - 1, 1, 1, h - 1);
117                         g.setColor(MetalLookAndFeel.getControlDarkShadow());
118                         g.drawRect(0, 0, w - 2, h - 2);
119                     }
120                     else {
121                         g.setColor(MetalLookAndFeel.getWhite());
122                         g.drawRect(1, 1, w - 2, h - 2);
123                         g.setColor(UIManager.getColor(
124                                 "Button.toolBarBorderBackground"));
125                         g.drawRect(0, 0, w - 2, h - 2);
126                     }
127                 }
128                 else {
129                    g.setColor(UIManager.getColor(
130                            "Button.disabledToolBarBorderBackground"));
131                    g.drawRect(0, 0, w - 2, h - 2);
132                 }
133             }
134         else if (model.isEnabled()) {
135                 boolean pressed = model.isPressed();
136                 boolean armed = model.isArmed();
137
138                 if ((c instanceof JButton) && ((JButton)c).isDefaultButton()) {
139                     g.setColor(MetalLookAndFeel.getControlDarkShadow());
140                     g.drawRect(0, 0, w - 1, h - 1);
141                     g.drawRect(1, 1, w - 3, h - 3);
142                 }
143                 else if (pressed) {
144                     g.setColor(MetalLookAndFeel.getControlDarkShadow());
145                     g.fillRect(0, 0, w, 2);
146                     g.fillRect(0, 2, 2, h - 2);
147                     g.fillRect(w - 1, 1, 1, h - 1);
148                     g.fillRect(1, h - 1, w - 2, 1);
149                 }
150                 else if (model.isRollover() && button.getClientProperty(
151                                NO_BUTTON_ROLLOVER) == null) {
152                     g.setColor(MetalLookAndFeel.getPrimaryControl());
153                     g.drawRect(0, 0, w - 1, h - 1);
154                     g.drawRect(2, 2, w - 5, h - 5);
155                     g.setColor(MetalLookAndFeel.getControlDarkShadow());
156                     g.drawRect(1, 1, w - 3, h - 3);
157                 }
158                 else {
159                     g.setColor(MetalLookAndFeel.getControlDarkShadow());
160                     g.drawRect(0, 0, w - 1, h - 1);
161                 }
162             }
163             else {
164                 g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
165                 g.drawRect(0, 0, w - 1, h - 1);
166                 if ((c instanceof JButton) && ((JButton)c).isDefaultButton()) {
167                     g.drawRect(1, 1, w - 3, h - 3);
168                 }
169             }
170         }
171
172         public Insets JavaDoc getBorderInsets( Component JavaDoc c ) {
173             return borderInsets;
174         }
175         public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets) {
176         newInsets.top = borderInsets.top;
177         newInsets.left = borderInsets.left;
178         newInsets.bottom = borderInsets.bottom;
179         newInsets.right = borderInsets.right;
180         return newInsets;
181     }
182     }
183
184     public static class InternalFrameBorder extends AbstractBorder implements UIResource {
185
186         private static final Insets JavaDoc insets = new Insets JavaDoc(5, 5, 5, 5);
187
188         private static final int corner = 14;
189
190         public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y,
191               int w, int h) {
192
193             Color JavaDoc background;
194             Color JavaDoc highlight;
195             Color JavaDoc shadow;
196
197             if (c instanceof JInternalFrame && ((JInternalFrame)c).isSelected()) {
198                 background = MetalLookAndFeel.getPrimaryControlDarkShadow();
199             highlight = MetalLookAndFeel.getPrimaryControlShadow();
200             shadow = MetalLookAndFeel.getPrimaryControlInfo();
201             } else {
202                 background = MetalLookAndFeel.getControlDarkShadow();
203             highlight = MetalLookAndFeel.getControlShadow();
204             shadow = MetalLookAndFeel.getControlInfo();
205             }
206
207               g.setColor(background);
208               // Draw outermost lines
209
g.drawLine( 1, 0, w-2, 0);
210               g.drawLine( 0, 1, 0, h-2);
211               g.drawLine( w-1, 1, w-1, h-2);
212               g.drawLine( 1, h-1, w-2, h-1);
213
214               // Draw the bulk of the border
215
for (int i = 1; i < 5; i++) {
216               g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
217               }
218
219               if (c instanceof JInternalFrame &&
220                                ((JInternalFrame)c).isResizable()) {
221                   g.setColor(highlight);
222                   // Draw the Long highlight lines
223
g.drawLine( corner+1, 3, w-corner, 3);
224                   g.drawLine( 3, corner+1, 3, h-corner);
225                   g.drawLine( w-2, corner+1, w-2, h-corner);
226                   g.drawLine( corner+1, h-2, w-corner, h-2);
227
228                   g.setColor(shadow);
229                   // Draw the Long shadow lines
230
g.drawLine( corner, 2, w-corner-1, 2);
231                   g.drawLine( 2, corner, 2, h-corner-1);
232                   g.drawLine( w-3, corner, w-3, h-corner-1);
233                   g.drawLine( corner, h-3, w-corner-1, h-3);
234               }
235
236           }
237
238           public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
239               return insets;
240           }
241           public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets) {
242           newInsets.top = insets.top;
243           newInsets.left = insets.left;
244           newInsets.bottom = insets.bottom;
245           newInsets.right = insets.right;
246           return newInsets;
247       }
248     }
249
250     /**
251      * Border for a Frame.
252      * @since 1.4
253      */

254     static class FrameBorder extends AbstractBorder implements UIResource {
255
256         private static final Insets JavaDoc insets = new Insets JavaDoc(5, 5, 5, 5);
257
258         private static final int corner = 14;
259
260         public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y,
261             int w, int h) {
262
263             Color JavaDoc background;
264             Color JavaDoc highlight;
265             Color JavaDoc shadow;
266
267             Window JavaDoc window = SwingUtilities.getWindowAncestor(c);
268             if (window != null && window.isActive()) {
269                 background = MetalLookAndFeel.getPrimaryControlDarkShadow();
270                 highlight = MetalLookAndFeel.getPrimaryControlShadow();
271                 shadow = MetalLookAndFeel.getPrimaryControlInfo();
272             } else {
273                 background = MetalLookAndFeel.getControlDarkShadow();
274                 highlight = MetalLookAndFeel.getControlShadow();
275                 shadow = MetalLookAndFeel.getControlInfo();
276             }
277
278             g.setColor(background);
279             // Draw outermost lines
280
g.drawLine( x+1, y+0, x+w-2, y+0);
281             g.drawLine( x+0, y+1, x+0, y +h-2);
282             g.drawLine( x+w-1, y+1, x+w-1, y+h-2);
283             g.drawLine( x+1, y+h-1, x+w-2, y+h-1);
284
285             // Draw the bulk of the border
286
for (int i = 1; i < 5; i++) {
287                 g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
288             }
289
290             if ((window instanceof Frame JavaDoc) && ((Frame JavaDoc) window).isResizable()) {
291                 g.setColor(highlight);
292                 // Draw the Long highlight lines
293
g.drawLine( corner+1, 3, w-corner, 3);
294                 g.drawLine( 3, corner+1, 3, h-corner);
295                 g.drawLine( w-2, corner+1, w-2, h-corner);
296                 g.drawLine( corner+1, h-2, w-corner, h-2);
297
298                 g.setColor(shadow);
299                 // Draw the Long shadow lines
300
g.drawLine( corner, 2, w-corner-1, 2);
301                 g.drawLine( 2, corner, 2, h-corner-1);
302                 g.drawLine( w-3, corner, w-3, h-corner-1);
303                 g.drawLine( corner, h-3, w-corner-1, h-3);
304             }
305
306         }
307
308         public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
309             return insets;
310         }
311           
312         public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets)
313         {
314             newInsets.top = insets.top;
315             newInsets.left = insets.left;
316             newInsets.bottom = insets.bottom;
317             newInsets.right = insets.right;
318             return newInsets;
319         }
320     }
321
322     /**
323      * Border for a Frame.
324      * @since 1.4
325      */

326     static class DialogBorder extends AbstractBorder implements UIResource
327     {
328         private static final Insets JavaDoc insets = new Insets JavaDoc(5, 5, 5, 5);
329         private static final int corner = 14;
330
331         protected Color JavaDoc getActiveBackground()
332         {
333             return MetalLookAndFeel.getPrimaryControlDarkShadow();
334         }
335
336         protected Color JavaDoc getActiveHighlight()
337         {
338             return MetalLookAndFeel.getPrimaryControlShadow();
339         }
340
341         protected Color JavaDoc getActiveShadow()
342         {
343             return MetalLookAndFeel.getPrimaryControlInfo();
344         }
345
346         protected Color JavaDoc getInactiveBackground()
347         {
348             return MetalLookAndFeel.getControlDarkShadow();
349         }
350
351         protected Color JavaDoc getInactiveHighlight()
352         {
353             return MetalLookAndFeel.getControlShadow();
354         }
355
356         protected Color JavaDoc getInactiveShadow()
357         {
358             return MetalLookAndFeel.getControlInfo();
359         }
360
361         public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y, int w, int h)
362         {
363             Color JavaDoc background;
364             Color JavaDoc highlight;
365             Color JavaDoc shadow;
366
367             Window JavaDoc window = SwingUtilities.getWindowAncestor(c);
368             if (window != null && window.isActive()) {
369                 background = getActiveBackground();
370                 highlight = getActiveHighlight();
371                 shadow = getActiveShadow();
372             } else {
373                 background = getInactiveBackground();
374                 highlight = getInactiveHighlight();
375                 shadow = getInactiveShadow();
376             }
377
378             g.setColor(background);
379             // Draw outermost lines
380
g.drawLine( x + 1, y + 0, x + w-2, y + 0);
381             g.drawLine( x + 0, y + 1, x + 0, y + h - 2);
382             g.drawLine( x + w - 1, y + 1, x + w - 1, y + h - 2);
383             g.drawLine( x + 1, y + h - 1, x + w - 2, y + h - 1);
384
385             // Draw the bulk of the border
386
for (int i = 1; i < 5; i++) {
387                 g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
388             }
389
390
391             if ((window instanceof Dialog JavaDoc) && ((Dialog JavaDoc) window).isResizable()) {
392                 g.setColor(highlight);
393                 // Draw the Long highlight lines
394
g.drawLine( corner+1, 3, w-corner, 3);
395                 g.drawLine( 3, corner+1, 3, h-corner);
396                 g.drawLine( w-2, corner+1, w-2, h-corner);
397                 g.drawLine( corner+1, h-2, w-corner, h-2);
398
399                 g.setColor(shadow);
400                 // Draw the Long shadow lines
401
g.drawLine( corner, 2, w-corner-1, 2);
402                 g.drawLine( 2, corner, 2, h-corner-1);
403                 g.drawLine( w-3, corner, w-3, h-corner-1);
404                 g.drawLine( corner, h-3, w-corner-1, h-3);
405             }
406             
407         }
408
409         public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
410             return insets;
411         }
412
413         public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets)
414         {
415             newInsets.top = insets.top;
416             newInsets.left = insets.left;
417             newInsets.bottom = insets.bottom;
418             newInsets.right = insets.right;
419             return newInsets;
420         }
421     }
422
423     /**
424      * Border for an Error Dialog.
425      * @since 1.4
426      */

427     static class ErrorDialogBorder extends DialogBorder implements UIResource
428     {
429         protected Color JavaDoc getActiveBackground() {
430             return UIManager.getColor("OptionPane.errorDialog.border.background");
431         }
432     }
433     
434
435     /**
436      * Border for a QuestionDialog. Also used for a JFileChooser and a
437      * JColorChooser..
438      * @since 1.4
439      */

440     static class QuestionDialogBorder extends DialogBorder implements UIResource
441     {
442         protected Color JavaDoc getActiveBackground() {
443             return UIManager.getColor("OptionPane.questionDialog.border.background");
444         }
445     }
446     
447
448     /**
449      * Border for a Warning Dialog.
450      * @since 1.4
451      */

452     static class WarningDialogBorder extends DialogBorder implements UIResource
453     {
454         protected Color JavaDoc getActiveBackground() {
455             return UIManager.getColor("OptionPane.warningDialog.border.background");
456         }
457     }
458     
459
460     /**
461      * Border for a Palette.
462      * @since 1.3
463      */

464     public static class PaletteBorder extends AbstractBorder implements UIResource {
465         private static final Insets JavaDoc insets = new Insets JavaDoc(1, 1, 1, 1);
466         int titleHeight = 0;
467
468         public void paintBorder( Component JavaDoc c, Graphics JavaDoc g, int x, int y, int w, int h ) {
469
470         g.translate(x,y);
471         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
472         g.drawLine(0, 1, 0, h-2);
473         g.drawLine(1, h-1, w-2, h-1);
474         g.drawLine(w-1, 1, w-1, h-2);
475         g.drawLine( 1, 0, w-2, 0);
476         g.drawRect(1,1, w-3, h-3);
477         g.translate(-x,-y);
478       
479     }
480
481         public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
482             return insets;
483         }
484
485         public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets) {
486         newInsets.top = insets.top;
487         newInsets.left = insets.left;
488         newInsets.bottom = insets.bottom;
489         newInsets.right = insets.right;
490         return newInsets;
491     }
492     }
493
494     public static class OptionDialogBorder extends AbstractBorder implements UIResource {
495         private static final Insets JavaDoc insets = new Insets JavaDoc(3, 3, 3, 3);
496         int titleHeight = 0;
497
498         public void paintBorder( Component JavaDoc c, Graphics JavaDoc g, int x, int y, int w, int h ) {
499
500         g.translate(x,y);
501
502             int messageType = JOptionPane.PLAIN_MESSAGE;
503             if (c instanceof JInternalFrame) {
504                 Object JavaDoc obj = ((JInternalFrame) c).getClientProperty(
505                               "JInternalFrame.messageType");
506                 if (obj != null && (obj instanceof Integer JavaDoc)) {
507                     messageType = ((Integer JavaDoc) obj).intValue();
508                 }
509             }
510
511             Color JavaDoc borderColor;
512
513         switch (messageType) {
514             case(JOptionPane.ERROR_MESSAGE):
515                 borderColor = UIManager.getColor(
516                     "OptionPane.errorDialog.border.background");
517                 break;
518             case(JOptionPane.QUESTION_MESSAGE):
519                 borderColor = UIManager.getColor(
520                     "OptionPane.questionDialog.border.background");
521                 break;
522             case(JOptionPane.WARNING_MESSAGE):
523                 borderColor = UIManager.getColor(
524                     "OptionPane.warningDialog.border.background");
525                 break;
526             case(JOptionPane.INFORMATION_MESSAGE):
527             case(JOptionPane.PLAIN_MESSAGE):
528             default:
529                 borderColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
530                 break;
531         }
532
533         g.setColor(borderColor);
534
535               // Draw outermost lines
536
g.drawLine( 1, 0, w-2, 0);
537               g.drawLine( 0, 1, 0, h-2);
538               g.drawLine( w-1, 1, w-1, h-2);
539               g.drawLine( 1, h-1, w-2, h-1);
540
541               // Draw the bulk of the border
542
for (int i = 1; i < 3; i++) {
543               g.drawRect(i, i, w-(i*2)-1, h-(i*2)-1);
544               }
545
546         g.translate(-x,-y);
547       
548     }
549
550         public Insets JavaDoc getBorderInsets(Component JavaDoc c) {
551             return insets;
552         }
553
554         public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets) {
555         newInsets.top = insets.top;
556         newInsets.left = insets.left;
557         newInsets.bottom = insets.bottom;
558         newInsets.right = insets.right;
559         return newInsets;
560     }
561     }
562
563
564     public static class MenuBarBorder extends AbstractBorder implements UIResource {
565         protected static Insets JavaDoc borderInsets = new Insets JavaDoc( 1, 0, 1, 0 );
566
567         public void paintBorder( Component JavaDoc c, Graphics JavaDoc g, int x, int y, int w, int h ) {
568         g.translate( x, y );
569
570             if (MetalLookAndFeel.usingOcean()) {
571                 // Only paint a border if we're not next to a horizontal
572
// toolbar
573
if (!MetalToolBarUI.doesMenuBarBorderToolBar((JMenuBar)c)) {
574                     g.setColor(MetalLookAndFeel.getControl());
575                     g.drawLine(0, h - 2, w, h - 2);
576                     g.setColor(UIManager.getColor("MenuBar.borderColor"));
577                     g.drawLine(0, h - 1, w, h - 1);
578                 }
579             }
580             else {
581                 g.setColor( MetalLookAndFeel.getControlShadow() );
582                 g.drawLine( 0, h-1, w, h-1 );
583             }
584
585         g.translate( -x, -y );
586
587         }
588
589         public Insets JavaDoc getBorderInsets( Component JavaDoc c ) {
590             return getBorderInsets(c, new Insets JavaDoc(0, 0, 0, 0));
591         }
592
593         public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets) {
594             if (MetalLookAndFeel.usingOcean()) {
595                 newInsets.set(0, 0, 2, 0);
596             }
597             else {
598                 newInsets.top = borderInsets.top;
599                 newInsets.left = borderInsets.left;
600                 newInsets.bottom = borderInsets.bottom;
601                 newInsets.right = borderInsets.right;
602             }
603         return newInsets;
604     }
605     }
606
607     public static class MenuItemBorder extends AbstractBorder implements UIResource {
608         protected static Insets JavaDoc borderInsets = new Insets JavaDoc( 2, 2, 2, 2 );
609
610         public void paintBorder( Component JavaDoc c, Graphics JavaDoc g, int x, int y, int w, int h ) {
611             JMenuItem b = (JMenuItem) c;
612         ButtonModel model = b.getModel();
613
614         g.translate( x, y );
615
616         if ( c.getParent() instanceof JMenuBar ) {
617             if ( model.isArmed() || model.isSelected() ) {
618                 g.setColor( MetalLookAndFeel.getControlDarkShadow() );
619                 g.drawLine( 0, 0, w - 2, 0 );
620                 g.drawLine( 0, 0, 0, h - 1 );
621                 g.drawLine( w - 2, 2, w - 2, h - 1 );
622
623                 g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
624                 g.drawLine( w - 1, 1, w - 1, h - 1 );
625
626                 g.setColor( MetalLookAndFeel.getMenuBackground() );
627                 g.drawLine( w - 1, 0, w - 1, 0 );
628             }
629         } else {
630             if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) ) {
631                 g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
632                 g.drawLine( 0, 0, w - 1, 0 );
633
634                 g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
635                 g.drawLine( 0, h - 1, w - 1, h - 1 );
636             } else {
637                 g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
638                 g.drawLine( 0, 0, 0, h - 1 );
639             }
640         }
641
642         g.translate( -x, -y );
643         }
644
645         public Insets JavaDoc getBorderInsets( Component JavaDoc c ) {
646             return borderInsets;
647         }
648
649         public Insets JavaDoc getBorderInsets(Component JavaDoc c, Insets JavaDoc newInsets) {
650         newInsets.top = borderInsets.top;
651         newInsets.left = borderInsets.left;
652         newInsets.bottom = borderInsets.bottom;
653         newInsets.right = borderInsets.right;
654         return newInsets;
655     }
656     }
657
658     public static class PopupMenuBorder extends AbstractBorder implements UIResource {
659         protected static Insets JavaDoc borderInsets = new Insets JavaDoc( 3, 1, 2, 1 );
660
661         public void paintBorder( Component JavaDoc c, Graphics JavaDoc g, int x, int y, int w, int h ) {
662         g.translate( x, y );
663
664             g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
665         g.drawRect( 0, 0, w - 1, h - 1 );
666
667             g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
668         g.drawLine( 1, 1, w - 2