1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45:
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64: import ;
65: import ;
66: import ;
67:
68:
69:
74: public class MetalBorders
75: {
76:
77:
78: private static Border buttonBorder;
79:
80:
81: private static Border toggleButtonBorder;
82:
83:
84: private static Border desktopIconBorder;
85:
86:
87: private static Border toolbarButtonBorder;
88:
89:
90: private static Border textFieldBorder;
91:
92:
93: private static Border textBorder;
94:
95:
96: private static Border rolloverBorder;
97:
98:
103: private static BasicBorders.MarginBorder marginBorder;
104:
105:
108: public static class ButtonBorder extends AbstractBorder implements UIResource
109: {
110:
111: protected static Insets borderInsets = new Insets(3, 3, 3, 3);
112:
113:
116: public ButtonBorder()
117: {
118:
119: }
120:
121:
131: public void paintBorder(Component c, Graphics g, int x, int y, int w,
132: int h)
133: {
134: ButtonModel bmodel = null;
135:
136: if (c instanceof AbstractButton)
137: bmodel = ((AbstractButton) c).getModel();
138:
139: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
140: Color shadow = MetalLookAndFeel.getControlShadow();
141: Color light = MetalLookAndFeel.getWhite();
142: Color middle = MetalLookAndFeel.getControl();
143:
144: if (c.isEnabled())
145: {
146:
147: g.setColor(darkShadow);
148: g.drawRect(x, y, w - 2, h - 2);
149:
150: if (!bmodel.isPressed())
151: {
152:
153: g.setColor(light);
154: g.drawRect(x + 1, y + 1, w - 2, h - 2);
155:
156:
157: g.setColor(middle);
158: g.drawRect(x + 1, y + h - 2, 0, 0);
159: g.drawRect(x + w - 2, y + 1, 0, 0);
160: }
161: else
162: {
163:
164: g.setColor(light);
165: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
166: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
167:
168:
169: g.setColor(middle);
170: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
171: g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
172:
173:
174: g.setColor(shadow);
175: g.drawRect(x + 1, y + h - 2, 0, 0);
176: g.drawRect(x + w - 2, y + 1, 0, 0);
177: }
178: }
179: else
180: {
181:
182: g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
183: g.drawRect(x, y, w - 2, h - 2);
184: }
185: }
186:
187:
194: public Insets getBorderInsets(Component c)
195: {
196: return getBorderInsets(c, null);
197: }
198:
199:
209: public Insets getBorderInsets(Component c, Insets newInsets)
210: {
211: if (newInsets == null)
212: newInsets = new Insets(0, 0, 0, 0);
213:
214: newInsets.bottom = borderInsets.bottom;
215: newInsets.left = borderInsets.left;
216: newInsets.right = borderInsets.right;
217: newInsets.top = borderInsets.top;
218: return newInsets;
219: }
220: }
221:
222:
225: static class DesktopIconBorder extends AbstractBorder
226: implements UIResource
227: {
228:
231: public DesktopIconBorder()
232: {
233:
234: }
235:
236:
243: public Insets getBorderInsets(Component c)
244: {
245: return getBorderInsets(c, null);
246: }
247:
248:
254: public Insets getBorderInsets(Component c, Insets newInsets)
255: {
256: if (newInsets == null)
257: newInsets = new Insets(3, 3, 2, 3);
258: else
259: {
260: newInsets.top = 3;
261: newInsets.left = 3;
262: newInsets.bottom = 2;
263: newInsets.right = 3;
264: }
265: return newInsets;
266: }
267:
268:
278: public void paintBorder(Component c, Graphics g, int x, int y, int w,
279: int h)
280: {
281: g.setColor(MetalLookAndFeel.getControlDarkShadow());
282: g.drawRect(x, y, w - 1, h - 1);
283: }
284:
285: }
286:
287:
290: public static class Flush3DBorder extends AbstractBorder
291: implements UIResource
292: {
293:
296: public Flush3DBorder()
297: {
298:
299: }
300:
301:
308: public Insets getBorderInsets(Component c)
309: {
310: return getBorderInsets(c, null);
311: }
312:
313:
319: public Insets getBorderInsets(Component c, Insets newInsets)
320: {
321: if (newInsets == null)
322: newInsets = new Insets(2, 2, 2, 2);
323: else
324: {
325: newInsets.top = 2;
326: newInsets.left = 2;
327: newInsets.bottom = 2;
328: newInsets.right = 2;
329: }
330: return newInsets;
331: }
332:
333:
343: public void paintBorder(Component c, Graphics g, int x, int y, int w,
344: int h)
345: {
346: Color savedColor = g.getColor();
347: g.setColor(MetalLookAndFeel.getControlDarkShadow());
348: g.drawRect(x, y, w - 2, h - 2);
349: g.setColor(MetalLookAndFeel.getControlHighlight());
350: g.drawRect(x + 1, y + 1, w - 2, h - 2);
351: g.setColor(MetalLookAndFeel.getControl());
352: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
353: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
354: g.setColor(savedColor);
355: }
356:
357: }
358:
359:
365: public static class PaletteBorder extends AbstractBorder
366: implements UIResource
367: {
368:
371: public PaletteBorder()
372: {
373:
374: }
375:
376:
383: public Insets getBorderInsets(Component c)
384: {
385: return getBorderInsets(c, null);
386: }
387:
388:
397: public Insets getBorderInsets(Component c, Insets newInsets)
398: {
399: if (newInsets == null)
400: newInsets = new Insets(1, 1, 1, 1);
401: else
402: {
403: newInsets.top = 1;
404: newInsets.left = 1;
405: newInsets.bottom = 1;
406: newInsets.right = 1;
407: }
408: return newInsets;
409: }
410:
411:
421: public void paintBorder(Component c, Graphics g, int x, int y, int w,
422: int h)
423: {
424: Color savedColor = g.getColor();
425:
426:
427: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
428: g.drawRect(x, y, w - 1, h - 1);
429:
430:
431: g.setColor(MetalLookAndFeel.getControl());
432: g.fillRect(x, y, 1, 1);
433: g.fillRect(x + w - 1, y, 1, 1);
434: g.fillRect(x + w - 1, y + h - 1, 1, 1);
435: g.fillRect(x, y + h - 1, 1, 1);
436: g.setColor(savedColor);
437: }
438:
439: }
440:
441:
444: public static class TextFieldBorder extends Flush3DBorder
445: implements UIResource
446: {
447:
450: public TextFieldBorder()
451: {
452:
453: }
454:
455:
465: public void paintBorder(Component c, Graphics g, int x, int y, int w,
466: int h)
467: {
468: boolean enabledTextBorder;
469: if (c instanceof JTextComponent)
470: {
471: JTextComponent tc = (JTextComponent) c;
472: enabledTextBorder = tc.isEnabled() && tc.isEditable();
473: }
474: else
475: enabledTextBorder = false;
476:
477: if (enabledTextBorder)
478: super.paintBorder(c, g, x, y, w, h);
479: else
480: {
481: Color savedColor = g.getColor();
482: g.setColor(MetalLookAndFeel.getControlShadow());
483: g.drawRect(x, y, w - 1, h - 1);
484: g.setColor(savedColor);
485: }
486: }
487:
488: }
489:
490:
493: public static class InternalFrameBorder extends AbstractBorder
494: implements UIResource
495: {
496:
499: public InternalFrameBorder()
500: {
501:
502: }
503:
504:
511: public Insets getBorderInsets(Component c)
512: {
513: return getBorderInsets(c, null);
514: }
515:
516:
522: public Insets getBorderInsets(Component c, Insets newInsets)
523: {
524: if (newInsets == null)
525: newInsets = new Insets(5, 5, 5, 5);
526: else
527: {
528: newInsets.top = 5;
529: newInsets.left = 5;
530: newInsets.bottom = 5;
531: newInsets.right = 5;
532: }
533: return newInsets;
534: }
535:
536:
546: public void paintBorder(Component c, Graphics g, int x, int y, int w,
547: int h)
548: {
549:
550: JInternalFrame f = (JInternalFrame) c;
551: if (f.isSelected())
552: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
553: else
554: g.setColor(MetalLookAndFeel.getControlDarkShadow());
555:
556:
557: g.fillRect(x, y, w, 5);
558: g.fillRect(x, y, 5, h);
559: g.fillRect(x + w - 5, y, 5, h);
560: g.fillRect(x, y + h - 5, w, 5);
561:
562:
563: g.setColor(MetalLookAndFeel.getControl());
564: g.fillRect(x, y, 1, 1);
565: g.fillRect(x + w - 1, y, 1, 1);
566: g.fillRect(x + w - 1, y + h - 1, 1, 1);
567: g.fillRect(x, y + h - 1, 1, 1);
568:
569:
570: g.setColor(MetalLookAndFeel.getBlack());
571: g.drawLine(x + 14, y + 2, x + w - 15, y + 2);
572: g.drawLine(x + 14, y + h - 3, x + w - 15, y + h - 3);
573: g.drawLine(x + 2, y + 14, x + 2, y + h - 15);
574: g.drawLine(x + w - 3, y + 14, x + w - 3, y + h - 15);
575:
576:
577: if (f.isSelected())
578: g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
579: else
580: g.setColor(MetalLookAndFeel.getControlShadow());
581: g.drawLine(x + 15, y + 3, x + w - 14, y + 3);
582: g.drawLine(x + 15, y + h - 2, x + w - 14, y + h - 2);
583: g.drawLine(x + 3, y + 15, x + 3, y + h - 14);
584: g.drawLine(x + w - 2, y + 15, x + w - 2, y + h - 14);
585: }
586:
587: }
588:
589:
593: public static class OptionDialogBorder extends AbstractBorder
594: implements UIResource
595: {
596:
597:
600: public OptionDialogBorder()
601: {
602:
603: }
604:
605:
612: public Insets getBorderInsets(Component c)
613: {
614: return getBorderInsets(c, null);
615: }
616:
617:
623: public Insets getBorderInsets(Component c, Insets newInsets)
624: {
625: if (newInsets == null)
626: newInsets = new Insets(3, 3, 3, 3);
627: else
628: {
629: newInsets.top = 3;
630: newInsets.left = 3;
631: newInsets.bottom = 3;
632: newInsets.right = 3;
633: }
634: return newInsets;
635: }
636:
637:
647: public void paintBorder(Component c, Graphics g, int x, int y, int w,
648: int h)
649: {
650:
651: JInternalFrame f = (JInternalFrame) c;
652: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
653: if (f.getContentPane() instanceof JOptionPane)
654: {
655: JOptionPane pane = (JOptionPane) f.getContentPane();
656: int type = pane.getMessageType();
657: UIDefaults defaults = UIManager.getLookAndFeelDefaults();
658: if (type == JOptionPane.QUESTION_MESSAGE)
659: {
660: Color bc = defaults.getColor(
661: "OptionPane.questionDialog.border.background");
662: if (bc != null)
663: g.setColor(bc);
664: }
665: if (type == JOptionPane.WARNING_MESSAGE)
666: {
667: Color bc = defaults.getColor(
668: "OptionPane.warningDialog.border.background");
669: if (bc != null)
670: g.setColor(bc);
671: }
672: else if (type == JOptionPane.ERROR_MESSAGE)
673: {
674: Color bc = defaults.getColor(
675: "OptionPane.errorDialog.border.background");
676: if (bc != null)
677: g.setColor(bc);
678: }
679: }
680:
681:
682: g.fillRect(x, y, w, 3);
683: g.fillRect(x, y, 3, h);
684: g.fillRect(x + w - 3, y, 3, h);
685: g.fillRect(x, y + h - 3, w, 3);
686:
687:
688: g.setColor(MetalLookAndFeel.getControl());
689: g.fillRect(x, y, 1, 1);
690: g.fillRect(x + w - 1, y, 1, 1);
691: g.fillRect(x + w - 1, y + h - 1, 1, 1);
692: g.fillRect(x, y + h - 1, 1, 1);
693:
694: }
695:
696: }
697:
698:
701: public static class MenuItemBorder extends AbstractBorder
702: implements UIResource
703: {
704:
705: protected static Insets borderInsets = new Insets(1, 1, 1, 1);
706:
707:
710: public MenuItemBorder()
711: {
712:
713: }
714:
715:
726: public void paintBorder(Component c, Graphics g, int x, int y, int w,
727: int h)
728: {
729: Color dark = MetalLookAndFeel.getPrimaryControlDarkShadow();
730: Color light = MetalLookAndFeel.getPrimaryControlHighlight();
731: if (c instanceof JMenu) {
732: JMenu menu = (JMenu) c;
733: if (menu.isSelected())
734: {
735: g.setColor(dark);
736: g.drawLine(x, y, x, y + h);
737: g.drawLine(x, y, x + w, y);
738: g.drawLine(x + w - 2, y + 1, x + w - 2, y + h);
739: g.setColor(light);
740: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h);
741: }
742: }
743: else if (c instanceof JMenuItem)
744: {
745: JMenuItem item = (JMenuItem) c;
746: if (item.isArmed())
747: {
748: g.setColor(dark);
749: g.drawLine(x, y, x + w, y);
750: g.setColor(light);
751: g.drawLine(x, y + h - 1, x + w, y + h - 1);
752: }
753: else
754: {
755:
756: g.setColor(light);
757: g.drawLine(x, y, x, y + h);
758: }
759: }
760: }
761:
762:
769: public Insets getBorderInsets(Component c)
770: {
771: return borderInsets;
772: }
773:
774:
784: public Insets getBorderInsets(Component c, Insets insets)
785: {
786: insets.left = borderInsets.left;
787: insets.top = borderInsets.top;
788: insets.bottom = borderInsets.bottom;
789: insets.right = borderInsets.right;
790: return insets;
791: }
792: }
793:
794:
797: public static class MenuBarBorder
798: extends AbstractBorder
799: implements UIResource
800: {
801:
802: protected static Insets borderInsets = new Insets(1, 0, 1, 0);
803:
804:
805: private static Color borderColor = new Color(153, 153, 153);
806:
807:
810: public MenuBarBorder()
811: {
812:
813: }
814:
815:
826: public void paintBorder(Component c, Graphics g, int x, int y, int w,
827: int h)
828: {
829: g.setColor(borderColor);
830: g.drawLine(x, y + h - 1, x + w, y + h - 1);
831: }
832:
833:
840: public Insets getBorderInsets(Component c)
841: {
842: return borderInsets;
843: }
844:
845:
855: public Insets getBorderInsets(Component c, Insets insets)
856: {
857: insets.left = borderInsets.left;
858: insets.top = borderInsets.top;
859: insets.bottom = borderInsets.bottom;
860: insets.right = borderInsets.right;
861: return insets;
862: }
863: }
864:
865:
868: public static class ScrollPaneBorder
869: extends AbstractBorder
870: implements UIResource
871: {
872:
873: private static Insets insets = new Insets(1, 1, 2, 2);
874:
875:
878: public ScrollPaneBorder()
879: {
880:
881: }
882:
883:
888: public Insets getBorderInsets(Component c)
889: {
890: return insets;
891: }
892:
893:
903: public void paintBorder(Component c, Graphics g, int x, int y,
904: int w, int h)
905: {
906: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
907: Color shadow = MetalLookAndFeel.getControlShadow();
908: Color light = MetalLookAndFeel.getWhite();
909: Color middle = MetalLookAndFeel.getControl();
910:
911:
912: g.setColor(darkShadow);
913: g.drawLine(x, y, x + w - 2, y);
914:
915:
916: g.drawLine(x, y, x, y + h - 2);
917:
918:
919: g.drawLine(x + w - 2, y, x + w - 2, y + h + 1);
920:
921:
922: g.drawLine(x + 2, y + h - 2, x + w - 2, y + h - 2);
923:
924:
925: g.setColor(light);
926: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
927:
928:
929: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
930:
931:
932: g.setColor(middle);
933: g.drawLine(x + w - 1, y, x + w - 1, y);
934: g.drawLine(x + w - 2, y + 2, x + w - 2, y + 2);
935: g.drawLine(x, y + h - 1, x, y + h - 1);
936: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
937:
938: }
939:
940: }
941:
942:
946: public static class RolloverButtonBorder
947: extends MetalBorders.ButtonBorder
948: {
949:
952: public RolloverButtonBorder()
953: {
954:
955: }
956:
957:
967: public void paintBorder(Component c, Graphics g, int x, int y, int w,
968: int h)
969: {
970: boolean mouseIsOver = false;
971: if (c instanceof AbstractButton)
972: {
973: ButtonModel bmodel = ((AbstractButton) c).getModel();
974: mouseIsOver = bmodel.isRollover();
975: }
976: if (mouseIsOver)
977: super.paintBorder(c, g, x, y, w, h);
978: }
979: }
980:
981:
984: static class RolloverMarginBorder extends AbstractBorder
985: {
986:
987: protected static Insets borderInsets = new Insets(3, 3, 3, 3);
988:
989:
992: public RolloverMarginBorder()
993: {
994:
995: }
996:
997:
1004: public Insets getBorderInsets(Component c)
1005: {
1006: return getBorderInsets(c, null);
1007: }
1008:
1009:
1018: public Insets getBorderInsets(Component c, Insets newInsets)
1019: {
1020: if (newInsets == null)
1021: newInsets = new Insets(0, 0, 0, 0);
1022:
1023: AbstractButton b = (AbstractButton) c;
1024: Insets margin = b.getMargin();
1025: newInsets.bottom = borderInsets.bottom;
1026: newInsets.left = borderInsets.left;
1027: newInsets.right = borderInsets.right;
1028: newInsets.top = borderInsets.top;
1029: return newInsets;
1030: }
1031: }
1032:
1033:
1036: public static class PopupMenuBorder
1037: extends AbstractBorder
1038: implements UIResource
1039: {
1040:
1041:
1042: protected static Insets borderInsets = new Insets(3, 1, 2, 1);
1043:
1044:
1047: public PopupMenuBorder()
1048: {
1049:
1050: }
1051:
1052:
1059: public Insets getBorderInsets(Component c)
1060: {
1061: return getBorderInsets(c, null);
1062: }
1063:
1064:
1071: public Insets getBorderInsets(Component c, Insets i)
1072: {
1073: Insets insets;
1074: if (i == null)
1075: insets = new Insets(borderInsets.top, borderInsets.left,
1076: borderInsets.bottom, borderInsets.right);
1077: else
1078: {
1079: insets = i;
1080: insets.top = borderInsets.top;
1081: insets.left = borderInsets.left;
1082: insets.bottom = borderInsets.bottom;
1083: insets.right = borderInsets.right;
1084: }
1085:
1086: return insets;
1087: }
1088:
1089:
1101: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1102: int h)
1103: {
1104: Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
1105: Color light = MetalLookAndFeel.getPrimaryControlHighlight();
1106:
1107:
1108: g.setColor(darkShadow);
1109: g.drawRect(x, y, w - 1, h - 1);
1110:
1111:
1112: g.setColor(light);
1113: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
1114: }
1115:
1116: }
1117:
1118:
1123: public static class ToggleButtonBorder
1124: extends ButtonBorder
1125: {
1126:
1129: public ToggleButtonBorder()
1130: {
1131:
1132: }
1133:
1134:
1144: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1145: int h)
1146: {
1147: ButtonModel bmodel = null;
1148:
1149: if (c instanceof AbstractButton)
1150: bmodel = ((AbstractButton) c).getModel();
1151:
1152: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
1153: Color shadow = MetalLookAndFeel.getControlShadow();
1154: Color light = MetalLookAndFeel.getWhite();
1155: Color middle = MetalLookAndFeel.getControl();
1156:
1157: if (c.isEnabled())
1158: {
1159:
1160: g.setColor(darkShadow);
1161: g.drawRect(x, y, w - 2, h - 2);
1162:
1163: if (!bmodel.isArmed())
1164: {
1165:
1166: g.setColor(light);
1167: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1168: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
1169: if (bmodel.isSelected())
1170: g.setColor(middle);
1171: g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
1172: g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
1173:
1174:
1175: g.setColor(shadow);
1176: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
1177: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
1178: }
1179: else
1180: {
1181:
1182: g.setColor(light);
1183: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
1184: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1185:
1186:
1187: g.setColor(shadow);
1188: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
1189: g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
1190:
1191:
1192: g.setColor(shadow);
1193: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
1194: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
1195:
1196: }
1197:
1198: g.setColor(middle);
1199: g.drawLine(x, y + h - 1, x, y + h - 1);
1200: g.drawLine(x + w - 1, y, x + w - 1, y);
1201: }
1202: else
1203: {
1204:
1205: g.setColor(MetalLookAndFeel.getControlDisabled());
1206: g.drawRect(x, y, w - 2, h - 2);
1207: }
1208: }
1209: }
1210:
1211:
1214: public static class ToolBarBorder extends AbstractBorder
1215: implements UIResource, SwingConstants
1216: {
1217:
1220: public ToolBarBorder()
1221: {
1222:
1223: }
1224:
1225:
1232: public Insets getBorderInsets(Component c)
1233: {
1234: return getBorderInsets(c, null);
1235: }
1236:
1237:
1243: public Insets getBorderInsets(Component c, Insets newInsets)
1244: {
1245: JToolBar tb = (JToolBar) c;
1246: if (tb.getOrientation() == JToolBar.HORIZONTAL)
1247: {
1248: if (newInsets == null)
1249: newInsets = new Insets(2, 16, 2, 2);
1250: else
1251: {
1252: newInsets.top = 2;
1253: newInsets.left = 16;
1254: newInsets.bottom = 2;
1255: newInsets.right = 2;
1256: }
1257: return newInsets;
1258: }
1259: else
1260: {
1261: if (newInsets == null)
1262: newInsets = new Insets(16, 2, 2, 2);
1263: else
1264: {
1265: newInsets.top = 16;
1266: newInsets.left = 2;
1267: newInsets.bottom = 2;
1268: newInsets.right = 2;
1269: }
1270: return newInsets;
1271: }
1272:
1273: }
1274:
1275:
1285: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1286: int h)
1287: {
1288:
1289: JToolBar tb = (JToolBar) c;
1290: if (tb.getOrientation() == JToolBar.HORIZONTAL)
1291: {
1292: MetalUtils.fillMetalPattern(tb, g, x + 2, y + 2, x + 11, y + h - 5,
1293: MetalLookAndFeel.getControlHighlight(),
1294: MetalLookAndFeel.getControlDarkShadow());
1295: }
1296: else
1297: {
1298: MetalUtils.fillMetalPattern(tb, g, x + 2, y + 2, x + w - 5, y + 11,
1299: MetalLookAndFeel.getControlHighlight(),
1300: MetalLookAndFeel.getControlDarkShadow());
1301: }
1302: }
1303:
1304: }
1305:
1306:
1311: public static class TableHeaderBorder extends AbstractBorder
1312: {
1313:
1316:
1317:
1318:
1319: protected Insets editorBorderInsets;
1320:
1321:
1324: public TableHeaderBorder()
1325: {
1326: editorBorderInsets = new Insets(1, 1, 1, 1);
1327: }
1328:
1329:
1334: public Insets getBorderInsets(Component c)
1335: {
1336: return editorBorderInsets;
1337: }
1338:
1339:
1349: public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
1350: {
1351: Color dark = MetalLookAndFeel.getControlDarkShadow();
1352: Color light = MetalLookAndFeel.getWhite();
1353: Color old = g.getColor();
1354: g.setColor(light);
1355: g.drawLine(x, y, x + w - 2, y);
1356: g.drawLine(x, y, x, y + h - 2);
1357: g.setColor(dark);
1358: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
1359: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1360: g.setColor(old);
1361: }
1362: }
1363:
1364:
1369: public static Border getButtonBorder()
1370: {
1371: if (buttonBorder == null)
1372: {
1373: Border outer = new ButtonBorder();
1374: Border inner = getMarginBorder();
1375: buttonBorder = new BorderUIResource.CompoundBorderUIResource
1376: (outer, inner);
1377: }
1378: return buttonBorder;
1379: }
1380:
1381:
1388: public static Border getToggleButtonBorder()
1389: {
1390: if (toggleButtonBorder == null)
1391: {
1392: Border outer = new ToggleButtonBorder();
1393: Border inner = getMarginBorder();
1394: toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource
1395: (outer, inner);
1396: }
1397: return toggleButtonBorder;
1398: }
1399:
1400:
1408: public static Border getDesktopIconBorder()
1409: {
1410: if (desktopIconBorder == null)
1411: desktopIconBorder = new DesktopIconBorder();
1412: return desktopIconBorder;
1413: }
1414:
1415:
1422: public static Border getTextFieldBorder()
1423: {
1424: if (textFieldBorder == null)
1425: {
1426: Border inner = getMarginBorder();
1427: Border outer = new TextFieldBorder();
1428: textFieldBorder =
1429: new BorderUIResource.CompoundBorderUIResource(outer, inner);
1430: }
1431: return textFieldBorder;
1432: }
1433:
1434:
1442: public static Border getTextBorder()
1443: {
1444: if (textBorder == null)
1445: {
1446: Border inner = getMarginBorder();
1447: Border outer = new Flush3DBorder();
1448: textBorder =
1449: new BorderUIResource.CompoundBorderUIResource(outer, inner);
1450: }
1451: return textBorder;
1452: }
1453:
1454:
1459: static Border getToolbarButtonBorder()
1460: {
1461: if (toolbarButtonBorder == null)
1462: {
1463: Border outer = new ButtonBorder();
1464: Border inner = new RolloverMarginBorder();
1465: toolbarButtonBorder = new BorderUIResource.CompoundBorderUIResource
1466: (outer, inner);
1467: }
1468: return toolbarButtonBorder;
1469: }
1470:
1471:
1476: static Border getMarginBorder()
1477: {
1478: if (marginBorder == null)
1479: marginBorder = new BasicBorders.MarginBorder();
1480: return marginBorder;
1481: }
1482:
1483:
1488: static Border getRolloverBorder()
1489: {
1490: if (rolloverBorder == null)
1491: {
1492: Border outer = new MetalBorders.RolloverButtonBorder();
1493: Border inner = MetalBorders.getMarginBorder();
1494: rolloverBorder = new BorderUIResource.CompoundBorderUIResource(outer,
1495: inner);
1496: }
1497: return rolloverBorder;
1498: }
1499:
1500: }