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:
67:
68:
73: public class MetalBorders
74: {
75:
76:
77: private static Border buttonBorder;
78:
79:
80: private static Border toggleButtonBorder;
81:
82:
83: private static Border desktopIconBorder;
84:
85:
86: private static Border toolbarButtonBorder;
87:
88:
89: private static Border textFieldBorder;
90:
91:
92: private static Border textBorder;
93:
94:
95: private static Border rolloverBorder;
96:
97:
102: private static BasicBorders.MarginBorder marginBorder;
103:
104:
107: public static class ButtonBorder extends AbstractBorder implements UIResource
108: {
109:
110: protected static Insets borderInsets = new Insets(3, 3, 3, 3);
111:
112:
115: public ButtonBorder()
116: {
117:
118: }
119:
120:
130: public void paintBorder(Component c, Graphics g, int x, int y, int w,
131: int h)
132: {
133:
134:
135:
136:
137:
138: if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
139: paintOceanButtonBorder(c, g, x, y, w, h);
140: else
141: {
142: ButtonModel bmodel = null;
143:
144: if (c instanceof AbstractButton)
145: bmodel = ((AbstractButton) c).getModel();
146:
147: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
148: Color shadow = MetalLookAndFeel.getControlShadow();
149: Color light = MetalLookAndFeel.getControlHighlight();
150: Color middle = MetalLookAndFeel.getControl();
151:
152: if (c.isEnabled())
153: {
154:
155: g.setColor(darkShadow);
156: g.drawRect(x, y, w - 2, h - 2);
157:
158: if (!bmodel.isPressed())
159: {
160:
161: g.setColor(light);
162: g.drawRect(x + 1, y + 1, w - 2, h - 2);
163:
164:
165: g.setColor(middle);
166: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
167: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
168: }
169: else
170: {
171:
172: g.setColor(light);
173: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
174: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
175:
176:
177: g.setColor(middle);
178: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
179: g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
180:
181:
182: g.setColor(shadow);
183: g.drawRect(x + 1, y + h - 2, 0, 0);
184: g.drawRect(x + w - 2, y + 1, 0, 0);
185: }
186: }
187: else
188: {
189:
190: g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
191: g.drawRect(x, y, w - 2, h - 2);
192: }
193: }
194: }
195:
196:
206: private void paintOceanButtonBorder(Component c, Graphics g, int x,
207: int y, int w, int h)
208: {
209: ButtonModel bmodel = null;
210:
211: if (c instanceof AbstractButton)
212: bmodel = ((AbstractButton) c).getModel();
213:
214: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
215: Color shadow = MetalLookAndFeel.getControlShadow();
216: Color light = MetalLookAndFeel.getControlHighlight();
217: Color middle = MetalLookAndFeel.getControl();
218:
219: if (c.isEnabled())
220: {
221: if (bmodel.isPressed())
222: {
223:
224: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
225: g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
226: }
227: else if (bmodel.isRollover())
228: {
229: g.setColor(shadow);
230: g.drawRect(x, y, w - 1, h - 1);
231: g.drawRect(x + 2, y + 2, w - 5, h - 5);
232: g.setColor(darkShadow);
233: g.drawRect(x + 1, y + 1, w - 3, h - 3);
234: }
235: else
236: {
237: g.setColor(darkShadow);
238: g.drawRect(x, y, w - 1, h - 1);
239: }
240: }
241: else
242: {
243:
244: g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
245: g.drawRect(x, y, w - 2, h - 2);
246: }
247: }
248:
249:
256: public Insets getBorderInsets(Component c)
257: {
258: return getBorderInsets(c, null);
259: }
260:
261:
271: public Insets getBorderInsets(Component c, Insets newInsets)
272: {
273: if (newInsets == null)
274: newInsets = new Insets(0, 0, 0, 0);
275:
276: newInsets.bottom = borderInsets.bottom;
277: newInsets.left = borderInsets.left;
278: newInsets.right = borderInsets.right;
279: newInsets.top = borderInsets.top;
280: return newInsets;
281: }
282: }
283:
284:
287: static class DesktopIconBorder extends AbstractBorder
288: implements UIResource
289: {
290:
293: public DesktopIconBorder()
294: {
295:
296: }
297:
298:
305: public Insets getBorderInsets(Component c)
306: {
307: return getBorderInsets(c, null);
308: }
309:
310:
316: public Insets getBorderInsets(Component c, Insets newInsets)
317: {
318: if (newInsets == null)
319: newInsets = new Insets(3, 3, 2, 3);
320: else
321: {
322: newInsets.top = 3;
323: newInsets.left = 3;
324: newInsets.bottom = 2;
325: newInsets.right = 3;
326: }
327: return newInsets;
328: }
329:
330:
340: public void paintBorder(Component c, Graphics g, int x, int y, int w,
341: int h)
342: {
343: g.setColor(MetalLookAndFeel.getControlDarkShadow());
344: g.drawRect(x, y, w - 1, h - 1);
345: }
346:
347: }
348:
349:
352: public static class Flush3DBorder extends AbstractBorder
353: implements UIResource
354: {
355:
358: public Flush3DBorder()
359: {
360:
361: }
362:
363:
370: public Insets getBorderInsets(Component c)
371: {
372: return getBorderInsets(c, null);
373: }
374:
375:
381: public Insets getBorderInsets(Component c, Insets newInsets)
382: {
383: if (newInsets == null)
384: newInsets = new Insets(2, 2, 2, 2);
385: else
386: {
387: newInsets.top = 2;
388: newInsets.left = 2;
389: newInsets.bottom = 2;
390: newInsets.right = 2;
391: }
392: return newInsets;
393: }
394:
395:
405: public void paintBorder(Component c, Graphics g, int x, int y, int w,
406: int h)
407: {
408: Color savedColor = g.getColor();
409: g.setColor(MetalLookAndFeel.getControlDarkShadow());
410: g.drawRect(x, y, w - 2, h - 2);
411: g.setColor(MetalLookAndFeel.getControlHighlight());
412: g.drawRect(x + 1, y + 1, w - 2, h - 2);
413: g.setColor(MetalLookAndFeel.getControl());
414: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
415: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
416: g.setColor(savedColor);
417: }
418:
419: }
420:
421:
427: public static class PaletteBorder extends AbstractBorder
428: implements UIResource
429: {
430:
433: public PaletteBorder()
434: {
435:
436: }
437:
438:
445: public Insets getBorderInsets(Component c)
446: {
447: return getBorderInsets(c, null);
448: }
449:
450:
459: public Insets getBorderInsets(Component c, Insets newInsets)
460: {
461: if (newInsets == null)
462: newInsets = new Insets(1, 1, 1, 1);
463: else
464: {
465: newInsets.top = 1;
466: newInsets.left = 1;
467: newInsets.bottom = 1;
468: newInsets.right = 1;
469: }
470: return newInsets;
471: }
472:
473:
483: public void paintBorder(Component c, Graphics g, int x, int y, int w,
484: int h)
485: {
486: Color savedColor = g.getColor();
487:
488:
489: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
490: g.drawRect(x, y, w - 1, h - 1);
491:
492:
493: g.setColor(MetalLookAndFeel.getControl());
494: g.fillRect(x, y, 1, 1);
495: g.fillRect(x + w - 1, y, 1, 1);
496: g.fillRect(x + w - 1, y + h - 1, 1, 1);
497: g.fillRect(x, y + h - 1, 1, 1);
498: g.setColor(savedColor);
499: }
500:
501: }
502:
503:
506: public static class TextFieldBorder extends Flush3DBorder
507: implements UIResource
508: {
509:
512: public TextFieldBorder()
513: {
514:
515: }
516:
517:
527: public void paintBorder(Component c, Graphics g, int x, int y, int w,
528: int h)
529: {
530: boolean enabledTextBorder;
531: if (c instanceof JTextComponent)
532: {
533: JTextComponent tc = (JTextComponent) c;
534: enabledTextBorder = tc.isEnabled() && tc.isEditable();
535: }
536: else
537: enabledTextBorder = false;
538:
539: if (enabledTextBorder)
540: super.paintBorder(c, g, x, y, w, h);
541: else
542: {
543: Color savedColor = g.getColor();
544: g.setColor(MetalLookAndFeel.getControlShadow());
545: g.drawRect(x, y, w - 1, h - 1);
546: g.setColor(savedColor);
547: }
548: }
549:
550: }
551:
552:
555: public static class InternalFrameBorder extends AbstractBorder
556: implements UIResource
557: {
558:
561: public InternalFrameBorder()
562: {
563:
564: }
565:
566:
573: public Insets getBorderInsets(Component c)
574: {
575: return getBorderInsets(c, null);
576: }
577:
578:
584: public Insets getBorderInsets(Component c, Insets newInsets)
585: {
586: if (newInsets == null)
587: newInsets = new Insets(5, 5, 5, 5);
588: else
589: {
590: newInsets.top = 5;
591: newInsets.left = 5;
592: newInsets.bottom = 5;
593: newInsets.right = 5;
594: }
595: return newInsets;
596: }
597:
598:
608: public void paintBorder(Component c, Graphics g, int x, int y, int w,
609: int h)
610: {
611:
612: JInternalFrame f = (JInternalFrame) c;
613: if (f.isSelected())
614: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
615: else
616: g.setColor(MetalLookAndFeel.getControlDarkShadow());
617:
618:
619: g.fillRect(x, y, w, 5);
620: g.fillRect(x, y, 5, h);
621: g.fillRect(x + w - 5, y, 5, h);
622: g.fillRect(x, y + h - 5, w, 5);
623:
624:
625: g.setColor(MetalLookAndFeel.getControl());
626: g.fillRect(x, y, 1, 1);
627: g.fillRect(x + w - 1, y, 1, 1);
628: g.fillRect(x + w - 1, y + h - 1, 1, 1);
629: g.fillRect(x, y + h - 1, 1, 1);
630:
631:
632: g.setColor(MetalLookAndFeel.getBlack());
633: g.drawLine(x + 14, y + 2, x + w - 15, y + 2);
634: g.drawLine(x + 14, y + h - 3, x + w - 15, y + h - 3);
635: g.drawLine(x + 2, y + 14, x + 2, y + h - 15);
636: g.drawLine(x + w - 3, y + 14, x + w - 3, y + h - 15);
637:
638:
639: if (f.isSelected())
640: g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
641: else
642: g.setColor(MetalLookAndFeel.getControlShadow());
643: g.drawLine(x + 15, y + 3, x + w - 14, y + 3);
644: g.drawLine(x + 15, y + h - 2, x + w - 14, y + h - 2);
645: g.drawLine(x + 3, y + 15, x + 3, y + h - 14);
646: g.drawLine(x + w - 2, y + 15, x + w - 2, y + h - 14);
647: }
648:
649: }
650:
651:
655: public static class OptionDialogBorder extends AbstractBorder
656: implements UIResource
657: {
658:
659:
662: public OptionDialogBorder()
663: {
664:
665: }
666:
667:
674: public Insets getBorderInsets(Component c)
675: {
676: return getBorderInsets(c, null);
677: }
678:
679:
685: public Insets getBorderInsets(Component c, Insets newInsets)
686: {
687: if (newInsets == null)
688: newInsets = new Insets(3, 3, 3, 3);
689: else
690: {
691: newInsets.top = 3;
692: newInsets.left = 3;
693: newInsets.bottom = 3;
694: newInsets.right = 3;
695: }
696: return newInsets;
697: }
698:
699:
709: public void paintBorder(Component c, Graphics g, int x, int y, int w,
710: int h)
711: {
712:
713: JInternalFrame f = (JInternalFrame) c;
714: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
715: if (f.getContentPane() instanceof JOptionPane)
716: {
717: JOptionPane pane = (JOptionPane) f.getContentPane();
718: int type = pane.getMessageType();
719: if (type == JOptionPane.QUESTION_MESSAGE)
720: {
721: Color bc = UIManager.getColor(
722: "OptionPane.questionDialog.border.background");
723: if (bc != null)
724: g.setColor(bc);
725: }
726: if (type == JOptionPane.WARNING_MESSAGE)
727: {
728: Color bc = UIManager.getColor(
729: "OptionPane.warningDialog.border.background");
730: if (bc != null)
731: g.setColor(bc);
732: }
733: else if (type == JOptionPane.ERROR_MESSAGE)
734: {
735: Color bc = UIManager.getColor(
736: "OptionPane.errorDialog.border.background");
737: if (bc != null)
738: g.setColor(bc);
739: }
740: }
741:
742:
743: g.fillRect(x, y, w, 3);
744: g.fillRect(x, y, 3, h);
745: g.fillRect(x + w - 3, y, 3, h);
746: g.fillRect(x, y + h - 3, w, 3);
747:
748:
749: g.setColor(MetalLookAndFeel.getControl());
750: g.fillRect(x, y, 1, 1);
751: g.fillRect(x + w - 1, y, 1, 1);
752: g.fillRect(x + w - 1, y + h - 1, 1, 1);
753: g.fillRect(x, y + h - 1, 1, 1);
754:
755: }
756:
757: }
758:
759:
762: public static class MenuItemBorder extends AbstractBorder
763: implements UIResource
764: {
765:
766: protected static Insets borderInsets = new Insets(1, 1, 1, 1);
767:
768:
771: public MenuItemBorder()
772: {
773:
774: }
775:
776:
787: public void paintBorder(Component c, Graphics g, int x, int y, int w,
788: int h)
789: {
790: Color dark = MetalLookAndFeel.getPrimaryControlDarkShadow();
791: Color light = MetalLookAndFeel.getPrimaryControlHighlight();
792: if (c instanceof JMenu) {
793: JMenu menu = (JMenu) c;
794: if (menu.isSelected())
795: {
796: g.setColor(dark);
797: g.drawLine(x, y, x, y + h);
798: g.drawLine(x, y, x + w, y);
799: g.drawLine(x + w - 2, y + 1, x + w - 2, y + h);
800: g.setColor(light);
801: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h);
802: }
803: }
804: else if (c instanceof JMenuItem)
805: {
806: JMenuItem item = (JMenuItem) c;
807: if (item.isArmed())
808: {
809: g.setColor(dark);
810: g.drawLine(x, y, x + w, y);
811: g.setColor(light);
812: g.drawLine(x, y + h - 1, x + w, y + h - 1);
813: }
814: else
815: {
816:
817: g.setColor(light);
818: g.drawLine(x, y, x, y + h);
819: }
820: }
821: }
822:
823:
830: public Insets getBorderInsets(Component c)
831: {
832: return borderInsets;
833: }
834:
835:
845: public Insets getBorderInsets(Component c, Insets insets)
846: {
847: insets.left = borderInsets.left;
848: insets.top = borderInsets.top;
849: insets.bottom = borderInsets.bottom;
850: insets.right = borderInsets.right;
851: return insets;
852: }
853: }
854:
855:
858: public static class MenuBarBorder
859: extends AbstractBorder
860: implements UIResource
861: {
862:
863: protected static Insets borderInsets = new Insets(1, 0, 1, 0);
864:
865:
866: private static Color borderColor = new Color(153, 153, 153);
867:
868:
871: public MenuBarBorder()
872: {
873:
874: }
875:
876:
887: public void paintBorder(Component c, Graphics g, int x, int y, int w,
888: int h)
889: {
890: g.setColor(borderColor);
891: g.drawLine(x, y + h - 1, x + w, y + h - 1);
892: }
893:
894:
901: public Insets getBorderInsets(Component c)
902: {
903: return borderInsets;
904: }
905:
906:
916: public Insets getBorderInsets(Component c, Insets insets)
917: {
918: insets.left = borderInsets.left;
919: insets.top = borderInsets.top;
920: insets.bottom = borderInsets.bottom;
921: insets.right = borderInsets.right;
922: return insets;
923: }
924: }
925:
926:
929: public static class ScrollPaneBorder
930: extends AbstractBorder
931: implements UIResource
932: {
933:
934: private static Insets insets = new Insets(1, 1, 2, 2);
935:
936:
939: public ScrollPaneBorder()
940: {
941:
942: }
943:
944:
949: public Insets getBorderInsets(Component c)
950: {
951: return insets;
952: }
953:
954:
964: public void paintBorder(Component c, Graphics g, int x, int y,
965: int w, int h)
966: {
967: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
968: Color shadow = MetalLookAndFeel.getControlShadow();
969: Color light = MetalLookAndFeel.getWhite();
970: Color middle = MetalLookAndFeel.getControl();
971:
972:
973: g.setColor(darkShadow);
974: g.drawLine(x, y, x + w - 2, y);
975:
976:
977: g.drawLine(x, y, x, y + h - 2);
978:
979:
980: g.drawLine(x + w - 2, y, x + w - 2, y + h + 1);
981:
982:
983: g.drawLine(x + 2, y + h - 2, x + w - 2, y + h - 2);
984:
985:
986: g.setColor(light);
987: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
988:
989:
990: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
991:
992:
993: g.setColor(middle);
994: g.drawLine(x + w - 1, y, x + w - 1, y);
995: g.drawLine(x + w - 2, y + 2, x + w - 2, y + 2);
996: g.drawLine(x, y + h - 1, x, y + h - 1);
997: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
998:
999: }
1000:
1001: }
1002:
1003:
1007: public static class RolloverButtonBorder
1008: extends MetalBorders.ButtonBorder
1009: {
1010:
1013: public RolloverButtonBorder()
1014: {
1015:
1016: }
1017:
1018:
1028: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1029: int h)
1030: {
1031: boolean mouseIsOver = false;
1032: if (c instanceof AbstractButton)
1033: {
1034: ButtonModel bmodel = ((AbstractButton) c).getModel();
1035: mouseIsOver = bmodel.isRollover();
1036: }
1037: if (mouseIsOver)
1038: super.paintBorder(c, g, x, y, w, h);
1039: }
1040: }
1041:
1042:
1045: static class RolloverMarginBorder extends AbstractBorder
1046: {
1047:
1048: protected static Insets borderInsets = new Insets(3, 3, 3, 3);
1049:
1050:
1053: public RolloverMarginBorder()
1054: {
1055:
1056: }
1057:
1058:
1065: public Insets getBorderInsets(Component c)
1066: {
1067: return getBorderInsets(c, null);
1068: }
1069:
1070:
1079: public Insets getBorderInsets(Component c, Insets newInsets)
1080: {
1081: if (newInsets == null)
1082: newInsets = new Insets(0, 0, 0, 0);
1083:
1084: AbstractButton b = (AbstractButton) c;
1085: Insets margin = b.getMargin();
1086: newInsets.bottom = borderInsets.bottom;
1087: newInsets.left = borderInsets.left;
1088: newInsets.right = borderInsets.right;
1089: newInsets.top = borderInsets.top;
1090: return newInsets;
1091: }
1092: }
1093:
1094:
1097: public static class PopupMenuBorder
1098: extends AbstractBorder
1099: implements UIResource
1100: {
1101:
1102:
1103: protected static Insets borderInsets = new Insets(3, 1, 2, 1);
1104:
1105:
1108: public PopupMenuBorder()
1109: {
1110:
1111: }
1112:
1113:
1120: public Insets getBorderInsets(Component c)
1121: {
1122: return getBorderInsets(c, null);
1123: }
1124:
1125:
1132: public Insets getBorderInsets(Component c, Insets i)
1133: {
1134: Insets insets;
1135: if (i == null)
1136: insets = new Insets(borderInsets.top, borderInsets.left,
1137: borderInsets.bottom, borderInsets.right);
1138: else
1139: {
1140: insets = i;
1141: insets.top = borderInsets.top;
1142: insets.left = borderInsets.left;
1143: insets.bottom = borderInsets.bottom;
1144: insets.right = borderInsets.right;
1145: }
1146:
1147: return insets;
1148: }
1149:
1150:
1162: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1163: int h)
1164: {
1165: Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
1166: Color light = MetalLookAndFeel.getPrimaryControlHighlight();
1167:
1168:
1169: g.setColor(darkShadow);
1170: g.drawRect(x, y, w - 1, h - 1);
1171:
1172:
1173: g.setColor(light);
1174: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
1175: }
1176:
1177: }
1178:
1179:
1184: public static class ToggleButtonBorder
1185: extends ButtonBorder
1186: {
1187:
1190: public ToggleButtonBorder()
1191: {
1192:
1193: }
1194:
1195:
1205: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1206: int h)
1207: {
1208: ButtonModel bmodel = null;
1209:
1210: if (c instanceof AbstractButton)
1211: bmodel = ((AbstractButton) c).getModel();
1212:
1213: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
1214: Color shadow = MetalLookAndFeel.getControlShadow();
1215: Color light = MetalLookAndFeel.getWhite();
1216: Color middle = MetalLookAndFeel.getControl();
1217:
1218: if (c.isEnabled())
1219: {
1220:
1221: g.setColor(darkShadow);
1222: g.drawRect(x, y, w - 2, h - 2);
1223:
1224: if (!bmodel.isArmed())
1225: {
1226:
1227: g.setColor(light);
1228: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1229: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
1230: if (bmodel.isSelected())
1231: g.setColor(middle);
1232: g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
1233: g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
1234:
1235:
1236: g.setColor(shadow);
1237: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
1238: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
1239: }
1240: else
1241: {
1242:
1243: g.setColor(light);
1244: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
1245: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1246:
1247:
1248: g.setColor(shadow);
1249: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
1250: g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
1251:
1252:
1253: g.setColor(shadow);
1254: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
1255: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
1256:
1257: }
1258:
1259: g.setColor(middle);
1260: g.drawLine(x, y + h - 1, x, y + h - 1);
1261: g.drawLine(x + w - 1, y, x + w - 1, y);
1262: }
1263: else
1264: {
1265:
1266: g.setColor(MetalLookAndFeel.getControlDisabled());
1267: g.drawRect(x, y, w - 2, h - 2);
1268: }
1269: }
1270: }
1271:
1272:
1275: public static class ToolBarBorder extends AbstractBorder
1276: implements UIResource, SwingConstants
1277: {
1278:
1281: public ToolBarBorder()
1282: {
1283:
1284: }
1285:
1286:
1293: public Insets getBorderInsets(Component c)
1294: {
1295: return getBorderInsets(c, null);
1296: }
1297:
1298:
1304: public Insets getBorderInsets(Component c, Insets newInsets)
1305: {
1306: JToolBar tb = (JToolBar) c;
1307: if (tb.getOrientation() == JToolBar.HORIZONTAL)
1308: {
1309: if (newInsets == null)
1310: newInsets = new Insets(2, 16, 2, 2);
1311: else
1312: {
1313: newInsets.top = 2;
1314: newInsets.left = 16;
1315: newInsets.bottom = 2;
1316: newInsets.right = 2;
1317: }
1318: return newInsets;
1319: }
1320: else
1321: {
1322: if (newInsets == null)
1323: newInsets = new Insets(16, 2, 2, 2);
1324: else
1325: {
1326: newInsets.top = 16;
1327: newInsets.left = 2;
1328: newInsets.bottom = 2;
1329: newInsets.right = 2;
1330: }
1331: return newInsets;
1332: }
1333:
1334: }
1335:
1336:
1346: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1347: int h)
1348: {
1349:
1350: JToolBar tb = (JToolBar) c;
1351: if (tb.getOrientation() == JToolBar.HORIZONTAL)
1352: {
1353: MetalUtils.fillMetalPattern(tb, g, x + 2, y + 2, x + 11, y + h - 5,
1354: MetalLookAndFeel.getControlHighlight(),
1355: MetalLookAndFeel.getControlDarkShadow());
1356: }
1357: else
1358: {
1359: MetalUtils.fillMetalPattern(tb, g, x + 2, y + 2, x + w - 5, y + 11,
1360: MetalLookAndFeel.getControlHighlight(),
1361: MetalLookAndFeel.getControlDarkShadow());
1362: }
1363: }
1364:
1365: }
1366:
1367:
1372: public static class TableHeaderBorder extends AbstractBorder
1373: {
1374:
1377:
1378:
1379:
1380: protected Insets editorBorderInsets;
1381:
1382:
1385: public TableHeaderBorder()
1386: {
1387: editorBorderInsets = new Insets(1, 1, 1, 1);
1388: }
1389:
1390:
1395: public Insets getBorderInsets(Component c)
1396: {
1397: return editorBorderInsets;
1398: }
1399:
1400:
1410: public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
1411: {
1412: Color dark = MetalLookAndFeel.getControlDarkShadow();
1413: Color light = MetalLookAndFeel.getWhite();
1414: Color old = g.getColor();
1415: g.setColor(light);
1416: g.drawLine(x, y, x + w - 2, y);
1417: g.drawLine(x, y, x, y + h - 2);
1418: g.setColor(dark);
1419: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
1420: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1421: g.setColor(old);
1422: }
1423: }
1424:
1425:
1430: public static Border getButtonBorder()
1431: {
1432: if (buttonBorder == null)
1433: {
1434: Border outer = new ButtonBorder();
1435: Border inner = getMarginBorder();
1436: buttonBorder = new BorderUIResource.CompoundBorderUIResource
1437: (outer, inner);
1438: }
1439: return buttonBorder;
1440: }
1441:
1442:
1449: public static Border getToggleButtonBorder()
1450: {
1451: if (toggleButtonBorder == null)
1452: {
1453: Border outer = new ToggleButtonBorder();
1454: Border inner = getMarginBorder();
1455: toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource
1456: (outer, inner);
1457: }
1458: return toggleButtonBorder;
1459: }
1460:
1461:
1469: public static Border getDesktopIconBorder()
1470: {
1471: if (desktopIconBorder == null)
1472: desktopIconBorder = new DesktopIconBorder();
1473: return desktopIconBorder;
1474: }
1475:
1476:
1483: public static Border getTextFieldBorder()
1484: {
1485: if (textFieldBorder == null)
1486: {
1487: Border inner = getMarginBorder();
1488: Border outer = new TextFieldBorder();
1489: textFieldBorder =
1490: new BorderUIResource.CompoundBorderUIResource(outer, inner);
1491: }
1492: return textFieldBorder;
1493: }
1494:
1495:
1503: public static Border getTextBorder()
1504: {
1505: if (textBorder == null)
1506: {
1507: Border inner = getMarginBorder();
1508: Border outer = new Flush3DBorder();
1509: textBorder =
1510: new BorderUIResource.CompoundBorderUIResource(outer, inner);
1511: }
1512: return textBorder;
1513: }
1514:
1515:
1520: static Border getToolbarButtonBorder()
1521: {
1522: if (toolbarButtonBorder == null)
1523: {
1524: Border outer = new ButtonBorder();
1525: Border inner = new RolloverMarginBorder();
1526: toolbarButtonBorder = new BorderUIResource.CompoundBorderUIResource
1527: (outer, inner);
1528: }
1529: return toolbarButtonBorder;
1530: }
1531:
1532:
1537: static Border getMarginBorder()
1538: {
1539: if (marginBorder == null)
1540: marginBorder = new BasicBorders.MarginBorder();
1541: return marginBorder;
1542: }
1543:
1544:
1549: static Border getRolloverBorder()
1550: {
1551: if (rolloverBorder == null)
1552: {
1553: Border outer = new MetalBorders.RolloverButtonBorder();
1554: Border inner = MetalBorders.getMarginBorder();
1555: rolloverBorder = new BorderUIResource.CompoundBorderUIResource(outer,
1556: inner);
1557: }
1558: return rolloverBorder;
1559: }
1560:
1561: }