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:
117: public static class ButtonBorder extends AbstractBorder implements UIResource
118: {
119:
120: protected static Insets borderInsets = new Insets(3, 3, 3, 3);
121:
122:
125: public ButtonBorder()
126: {
127:
128: }
129:
130:
140: public void paintBorder(Component c, Graphics g, int x, int y, int w,
141: int h)
142: {
143:
144:
145:
146:
147:
148: if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
149: paintOceanButtonBorder(c, g, x, y, w, h);
150: else
151: paintDefaultButtonBorder(c, g, x, y, w, h);
152: }
153:
154:
164: private void paintDefaultButtonBorder(Component c, Graphics g, int x,
165: int y, int w, int h)
166: {
167: ButtonModel bmodel = null;
168:
169:
170:
171: if (c instanceof AbstractButton)
172: bmodel = ((AbstractButton) c).getModel();
173: else
174: throw new IllegalStateException("A ButtonBorder is supposed to work "
175: + "only with AbstractButton and"
176: + "subclasses.");
177:
178: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
179: Color shadow = MetalLookAndFeel.getControlShadow();
180: Color light = MetalLookAndFeel.getControlHighlight();
181: Color middle = MetalLookAndFeel.getControl();
182:
183: if (c.isEnabled())
184: {
185:
186: g.setColor(darkShadow);
187: g.drawRect(x, y, w - 2, h - 2);
188:
189:
190:
191: if (c instanceof JButton && ((JButton) c).isDefaultButton())
192: {
193: g.drawRect(x + 1, y + 1, w - 4, h - 4);
194:
195: g.setColor(light);
196: g.drawLine(x + 2, y + 2, x + w - 4, y + 2);
197: g.drawLine(x + 2, y + 2, x + 2, y + h - 4);
198: g.drawLine(x + 2, y + h - 1, x + w - 1, y + h - 1);
199: g.drawLine(x + w - 1, y + 2, x + w - 1, y + h - 1);
200:
201: g.setColor(middle);
202: g.fillRect(x + w - 2, y + 2, 1, 1);
203: g.fillRect(x + 2, y + h - 2, 1, 1);
204: }
205: else
206: {
207:
208:
209: if (! (bmodel.isPressed() && bmodel.isArmed()))
210: {
211:
212: g.setColor(light);
213: g.drawRect(x + 1, y + 1, w - 2, h - 2);
214:
215:
216: g.setColor(middle);
217: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
218: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
219: }
220:
221:
222: else
223: {
224:
225: g.setColor(light);
226: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
227: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
228:
229:
230: g.setColor(middle);
231: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
232: g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
233:
234:
235: g.setColor(shadow);
236: g.drawRect(x + 1, y + h - 2, 0, 0);
237: g.drawRect(x + w - 2, y + 1, 0, 0);
238: }
239: }
240: }
241: else
242: {
243:
244: g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
245: g.drawRect(x, y, w - 2, h - 2);
246: }
247: }
248:
249:
259: private void paintOceanButtonBorder(Component c, Graphics g, int x,
260: int y, int w, int h)
261: {
262: ButtonModel bmodel = null;
263:
264:
265:
266: if (c instanceof AbstractButton)
267: bmodel = ((AbstractButton) c).getModel();
268: else
269: throw new IllegalStateException("A ButtonBorder is supposed to work "
270: + "only with AbstractButton and"
271: + "subclasses.");
272:
273: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
274: Color shadow = MetalLookAndFeel.getControlShadow();
275: Color light = MetalLookAndFeel.getControlHighlight();
276: Color middle = MetalLookAndFeel.getControl();
277:
278: if (c.isEnabled())
279: {
280:
281:
282:
283: if (bmodel.isPressed() || ((c instanceof JButton)
284: && ((JButton) c).isDefaultButton()))
285: {
286:
287: g.setColor(darkShadow);
288: g.drawRect(x, y, w - 1, h - 1);
289: g.drawRect(x + 1, y + 1, w - 3, h - 3);
290: }
291: else if (bmodel.isRollover() && !(c.getParent() instanceof JToolBar))
292: {
293:
294:
295: g.setColor(shadow);
296: g.drawRect(x, y, w - 1, h - 1);
297: g.drawRect(x + 2, y + 2, w - 5, h - 5);
298: g.setColor(darkShadow);
299: g.drawRect(x + 1, y + 1, w - 3, h - 3);
300: }
301: else
302: {
303: g.setColor(darkShadow);
304: g.drawRect(x, y, w - 1, h - 1);
305: }
306: }
307: else
308: {
309:
310: g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
311: g.drawRect(x, y, w - 2, h - 2);
312: }
313: }
314:
315:
322: public Insets getBorderInsets(Component c)
323: {
324: return borderInsets;
325: }
326:
327:
337: public Insets getBorderInsets(Component c, Insets newInsets)
338: {
339: newInsets.bottom = borderInsets.bottom;
340: newInsets.left = borderInsets.left;
341: newInsets.right = borderInsets.right;
342: newInsets.top = borderInsets.top;
343: return newInsets;
344: }
345: }
346:
347:
350: static class DesktopIconBorder extends AbstractBorder
351: implements UIResource
352: {
353:
356: public DesktopIconBorder()
357: {
358:
359: }
360:
361:
368: public Insets getBorderInsets(Component c)
369: {
370: return getBorderInsets(c, null);
371: }
372:
373:
379: public Insets getBorderInsets(Component c, Insets newInsets)
380: {
381: if (newInsets == null)
382: newInsets = new Insets(3, 3, 2, 3);
383: else
384: {
385: newInsets.top = 3;
386: newInsets.left = 3;
387: newInsets.bottom = 2;
388: newInsets.right = 3;
389: }
390: return newInsets;
391: }
392:
393:
403: public void paintBorder(Component c, Graphics g, int x, int y, int w,
404: int h)
405: {
406: g.setColor(MetalLookAndFeel.getControlDarkShadow());
407: g.drawRect(x, y, w - 1, h - 1);
408: }
409:
410: }
411:
412:
415: public static class Flush3DBorder extends AbstractBorder
416: implements UIResource
417: {
418: private static final Insets borderInsets = new Insets(2, 2, 2, 2);
419:
420:
423: public Flush3DBorder()
424: {
425:
426: }
427:
428:
435: public Insets getBorderInsets(Component c)
436: {
437: return borderInsets;
438: }
439:
440:
450: public Insets getBorderInsets(Component c, Insets newInsets)
451: {
452: newInsets.top = borderInsets.top;
453: newInsets.left = borderInsets.left;
454: newInsets.bottom = borderInsets.bottom;
455: newInsets.right = borderInsets.right;
456: return newInsets;
457: }
458:
459:
469: public void paintBorder(Component c, Graphics g, int x, int y, int w,
470: int h)
471: {
472: Color savedColor = g.getColor();
473: g.setColor(MetalLookAndFeel.getControlDarkShadow());
474: g.drawRect(x, y, w - 2, h - 2);
475: g.setColor(MetalLookAndFeel.getControlHighlight());
476: g.drawRect(x + 1, y + 1, w - 2, h - 2);
477: g.setColor(MetalLookAndFeel.getControl());
478: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
479: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
480: g.setColor(savedColor);
481: }
482:
483: }
484:
485:
491: public static class PaletteBorder extends AbstractBorder
492: implements UIResource
493: {
494: private static final Insets borderInsets = new Insets(1, 1, 1, 1);
495:
496:
499: public PaletteBorder()
500: {
501:
502: }
503:
504:
511: public Insets getBorderInsets(Component c)
512: {
513: return borderInsets;
514: }
515:
516:
526: public Insets getBorderInsets(Component c, Insets newInsets)
527: {
528: newInsets.top = borderInsets.top;
529: newInsets.left = borderInsets.left;
530: newInsets.bottom = borderInsets.bottom;
531: newInsets.right = borderInsets.right;
532: return newInsets;
533: }
534:
535:
545: public void paintBorder(Component c, Graphics g, int x, int y, int w,
546: int h)
547: {
548: Color savedColor = g.getColor();
549:
550:
551: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
552: g.drawRect(x, y, w - 1, h - 1);
553:
554:
555: g.setColor(MetalLookAndFeel.getControl());
556: g.fillRect(x, y, 1, 1);
557: g.fillRect(x + w - 1, y, 1, 1);
558: g.fillRect(x + w - 1, y + h - 1, 1, 1);
559: g.fillRect(x, y + h - 1, 1, 1);
560: g.setColor(savedColor);
561: }
562:
563: }
564:
565:
568: public static class TextFieldBorder extends Flush3DBorder
569: implements UIResource
570: {
571:
574: public TextFieldBorder()
575: {
576:
577: }
578:
579:
589: public void paintBorder(Component c, Graphics g, int x, int y, int w,
590: int h)
591: {
592: boolean enabledTextBorder;
593: if (c instanceof JTextComponent)
594: {
595: JTextComponent tc = (JTextComponent) c;
596: enabledTextBorder = tc.isEnabled() && tc.isEditable();
597: }
598: else
599: enabledTextBorder = false;
600:
601: if (enabledTextBorder)
602: super.paintBorder(c, g, x, y, w, h);
603: else
604: {
605: Color savedColor = g.getColor();
606: g.setColor(MetalLookAndFeel.getControlShadow());
607: g.drawRect(x, y, w - 1, h - 1);
608: g.setColor(savedColor);
609: }
610: }
611:
612: }
613:
614:
617: public static class InternalFrameBorder extends AbstractBorder
618: implements UIResource
619: {
620: private static final Insets borderInsets = new Insets(5, 5, 5, 5);
621:
622:
625: public InternalFrameBorder()
626: {
627:
628: }
629:
630:
637: public Insets getBorderInsets(Component c)
638: {
639: return borderInsets;
640: }
641:
642:
652: public Insets getBorderInsets(Component c, Insets newInsets)
653: {
654: newInsets.top = borderInsets.top;
655: newInsets.left = borderInsets.left;
656: newInsets.bottom = borderInsets.bottom;
657: newInsets.right = borderInsets.right;
658: return newInsets;
659: }
660:
661:
671: public void paintBorder(Component c, Graphics g, int x, int y, int w,
672: int h)
673: {
674:
675: JInternalFrame f = (JInternalFrame) c;
676: if (f.isSelected())
677: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
678: else
679: g.setColor(MetalLookAndFeel.getControlDarkShadow());
680:
681:
682: g.fillRect(x, y, w, 5);
683: g.fillRect(x, y, 5, h);
684: g.fillRect(x + w - 5, y, 5, h);
685: g.fillRect(x, y + h - 5, w, 5);
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: g.setColor(MetalLookAndFeel.getBlack());
696: g.drawLine(x + 14, y + 2, x + w - 15, y + 2);
697: g.drawLine(x + 14, y + h - 3, x + w - 15, y + h - 3);
698: g.drawLine(x + 2, y + 14, x + 2, y + h - 15);
699: g.drawLine(x + w - 3, y + 14, x + w - 3, y + h - 15);
700:
701:
702: if (f.isSelected())
703: g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
704: else
705: g.setColor(MetalLookAndFeel.getControlShadow());
706: g.drawLine(x + 15, y + 3, x + w - 14, y + 3);
707: g.drawLine(x + 15, y + h - 2, x + w - 14, y + h - 2);
708: g.drawLine(x + 3, y + 15, x + 3, y + h - 14);
709: g.drawLine(x + w - 2, y + 15, x + w - 2, y + h - 14);
710: }
711:
712: }
713:
714:
718: public static class OptionDialogBorder extends AbstractBorder
719: implements UIResource
720: {
721:
722:
725: public OptionDialogBorder()
726: {
727:
728: }
729:
730:
737: public Insets getBorderInsets(Component c)
738: {
739: return getBorderInsets(c, null);
740: }
741:
742:
748: public Insets getBorderInsets(Component c, Insets newInsets)
749: {
750: if (newInsets == null)
751: newInsets = new Insets(3, 3, 3, 3);
752: else
753: {
754: newInsets.top = 3;
755: newInsets.left = 3;
756: newInsets.bottom = 3;
757: newInsets.right = 3;
758: }
759: return newInsets;
760: }
761:
762:
772: public void paintBorder(Component c, Graphics g, int x, int y, int w,
773: int h)
774: {
775:
776: JInternalFrame f = (JInternalFrame) c;
777: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
778: if (f.getContentPane() instanceof JOptionPane)
779: {
780: JOptionPane pane = (JOptionPane) f.getContentPane();
781: int type = pane.getMessageType();
782: if (type == JOptionPane.QUESTION_MESSAGE)
783: {
784: Color bc = UIManager.getColor(
785: "OptionPane.questionDialog.border.background");
786: if (bc != null)
787: g.setColor(bc);
788: }
789: if (type == JOptionPane.WARNING_MESSAGE)
790: {
791: Color bc = UIManager.getColor(
792: "OptionPane.warningDialog.border.background");
793: if (bc != null)
794: g.setColor(bc);
795: }
796: else if (type == JOptionPane.ERROR_MESSAGE)
797: {
798: Color bc = UIManager.getColor(
799: "OptionPane.errorDialog.border.background");
800: if (bc != null)
801: g.setColor(bc);
802: }
803: }
804:
805:
806: g.fillRect(x, y, w, 3);
807: g.fillRect(x, y, 3, h);
808: g.fillRect(x + w - 3, y, 3, h);
809: g.fillRect(x, y + h - 3, w, 3);
810:
811:
812: g.setColor(MetalLookAndFeel.getControl());
813: g.fillRect(x, y, 1, 1);
814: g.fillRect(x + w - 1, y, 1, 1);
815: g.fillRect(x + w - 1, y + h - 1, 1, 1);
816: g.fillRect(x, y + h - 1, 1, 1);
817:
818: }
819:
820: }
821:
822:
825: public static class MenuItemBorder extends AbstractBorder
826: implements UIResource
827: {
828:
829: protected static Insets borderInsets = new Insets(2, 2, 2, 2);
830:
831:
834: public MenuItemBorder()
835: {
836:
837: }
838:
839:
850: public void paintBorder(Component c, Graphics g, int x, int y, int w,
851: int h)
852: {
853: Color dark = MetalLookAndFeel.getPrimaryControlDarkShadow();
854: Color light = MetalLookAndFeel.getPrimaryControlHighlight();
855: if (c instanceof JMenu)
856: {
857: JMenu menu = (JMenu) c;
858: if (menu.isSelected())
859: {
860: g.setColor(dark);
861: g.drawLine(x, y, x, y + h);
862: g.drawLine(x, y, x + w, y);
863: g.drawLine(x + w - 2, y + 1, x + w - 2, y + h);
864: g.setColor(light);
865: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h);
866: }
867: }
868: else if (c instanceof JMenuItem)
869: {
870: JMenuItem item = (JMenuItem) c;
871: if (item.isArmed())
872: {
873: g.setColor(dark);
874: g.drawLine(x, y, x + w, y);
875: g.setColor(light);
876: g.drawLine(x, y + h - 1, x + w, y + h - 1);
877: }
878: else
879: {
880:
881: g.setColor(light);
882: g.drawLine(x, y, x, y + h);
883: }
884: }
885: }
886:
887:
894: public Insets getBorderInsets(Component c)
895: {
896: return borderInsets;
897: }
898:
899:
909: public Insets getBorderInsets(Component c, Insets insets)
910: {
911: insets.left = borderInsets.left;
912: insets.top = borderInsets.top;
913: insets.bottom = borderInsets.bottom;
914: insets.right = borderInsets.right;
915: return insets;
916: }
917: }
918:
919:
922: public static class MenuBarBorder
923: extends AbstractBorder
924: implements UIResource
925: {
926:
927: protected static Insets borderInsets = new Insets(1, 0, 1, 0);
928:
929:
932: public MenuBarBorder()
933: {
934: }
935:
936:
947: public void paintBorder(Component c, Graphics g, int x, int y, int w,
948: int h)
949: {
950:
951:
952:
953:
954:
955:
956: if(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
957: g.setColor(UIManager.getColor("MenuBar.borderColor"));
958: else
959: g.setColor(MetalLookAndFeel.getControlShadow());
960:
961: g.drawLine(x, y + h - 1, x + w, y + h - 1);
962: }
963:
964:
971: public Insets getBorderInsets(Component c)
972: {
973: return borderInsets;
974: }
975:
976:
986: public Insets getBorderInsets(Component c, Insets insets)
987: {
988: insets.left = borderInsets.left;
989: insets.top = borderInsets.top;
990: insets.bottom = borderInsets.bottom;
991: insets.right = borderInsets.right;
992: return insets;
993: }
994: }
995:
996:
999: public static class ScrollPaneBorder
1000: extends AbstractBorder
1001: implements UIResource
1002: {
1003:
1004: private static Insets insets = new Insets(1, 1, 2, 2);
1005:
1006:
1009: public ScrollPaneBorder()
1010: {
1011:
1012: }
1013:
1014:
1019: public Insets getBorderInsets(Component c)
1020: {
1021: return insets;
1022: }
1023:
1024:
1034: public void paintBorder(Component c, Graphics g, int x, int y,
1035: int w, int h)
1036: {
1037: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
1038: Color shadow = MetalLookAndFeel.getControlShadow();
1039: Color light = MetalLookAndFeel.getWhite();
1040: Color middle = MetalLookAndFeel.getControl();
1041:
1042:
1043: g.setColor(darkShadow);
1044: g.drawLine(x, y, x + w - 2, y);
1045:
1046:
1047: g.drawLine(x, y, x, y + h - 2);
1048:
1049:
1050: g.drawLine(x + w - 2, y, x + w - 2, y + h + 1);
1051:
1052:
1053: g.drawLine(x + 2, y + h - 2, x + w - 2, y + h - 2);
1054:
1055:
1056: g.setColor(light);
1057: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
1058:
1059:
1060: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
1061:
1062:
1063: g.setColor(middle);
1064: g.drawLine(x + w - 1, y, x + w - 1, y);
1065: g.drawLine(x + w - 2, y + 2, x + w - 2, y + 2);
1066: g.drawLine(x, y + h - 1, x, y + h - 1);
1067: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
1068:
1069: }
1070:
1071: }
1072:
1073:
1077: public static class RolloverButtonBorder
1078: extends MetalBorders.ButtonBorder
1079: {
1080:
1083: public RolloverButtonBorder()
1084: {
1085:
1086: }
1087:
1088:
1098: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1099: int h)
1100: {
1101:
1102:
1103:
1104: super.paintBorder(c, g, x, y, w, h);
1105: }
1106: }
1107:
1108:
1111: static class RolloverMarginBorder extends AbstractBorder
1112: {
1113:
1114: protected static Insets borderInsets = new Insets(3, 3, 3, 3);
1115:
1116:
1119: public RolloverMarginBorder()
1120: {
1121:
1122: }
1123:
1124:
1131: public Insets getBorderInsets(Component c)
1132: {
1133: return getBorderInsets(c, null);
1134: }
1135:
1136:
1145: public Insets getBorderInsets(Component c, Insets newInsets)
1146: {
1147: if (newInsets == null)
1148: newInsets = new Insets(0, 0, 0, 0);
1149:
1150: AbstractButton b = (AbstractButton) c;
1151: Insets margin = b.getMargin();
1152: newInsets.bottom = borderInsets.bottom;
1153: newInsets.left = borderInsets.left;
1154: newInsets.right = borderInsets.right;
1155: newInsets.top = borderInsets.top;
1156: return newInsets;
1157: }
1158: }
1159:
1160:
1163: public static class PopupMenuBorder
1164: extends AbstractBorder
1165: implements UIResource
1166: {
1167:
1168:
1169: protected static Insets borderInsets = new Insets(3, 1, 2, 1);
1170:
1171:
1174: public PopupMenuBorder()
1175: {
1176:
1177: }
1178:
1179:
1186: public Insets getBorderInsets(Component c)
1187: {
1188: return getBorderInsets(c, null);
1189: }
1190:
1191:
1198: public Insets getBorderInsets(Component c, Insets i)
1199: {
1200: Insets insets;
1201: if (i == null)
1202: insets = new Insets(borderInsets.top, borderInsets.left,
1203: borderInsets.bottom, borderInsets.right);
1204: else
1205: {
1206: insets = i;
1207: insets.top = borderInsets.top;
1208: insets.left = borderInsets.left;
1209: insets.bottom = borderInsets.bottom;
1210: insets.right = borderInsets.right;
1211: }
1212:
1213: return insets;
1214: }
1215:
1216:
1228: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1229: int h)
1230: {
1231: Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
1232: Color light = MetalLookAndFeel.getPrimaryControlHighlight();
1233:
1234:
1235: g.setColor(darkShadow);
1236: g.drawRect(x, y, w - 1, h - 1);
1237:
1238:
1239: g.setColor(light);
1240: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
1241: }
1242:
1243: }
1244:
1245:
1250: public static class ToggleButtonBorder
1251: extends ButtonBorder
1252: {
1253:
1256: public ToggleButtonBorder()
1257: {
1258:
1259: }
1260:
1261:
1271: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1272: int h)
1273: {
1274: ButtonModel bmodel = null;
1275:
1276: if (c instanceof AbstractButton)
1277: bmodel = ((AbstractButton) c).getModel();
1278:
1279: Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
1280: Color shadow = MetalLookAndFeel.getControlShadow();
1281: Color light = MetalLookAndFeel.getWhite();
1282: Color middle = MetalLookAndFeel.getControl();
1283:
1284: if (c.isEnabled())
1285: {
1286:
1287: g.setColor(darkShadow);
1288: g.drawRect(x, y, w - 2, h - 2);
1289:
1290: if (!bmodel.isArmed())
1291: {
1292:
1293: g.setColor(light);
1294: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1295: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
1296: if (bmodel.isSelected())
1297: g.setColor(middle);
1298: g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
1299: g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
1300:
1301:
1302: g.setColor(shadow);
1303: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
1304: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
1305: }
1306: else
1307: {
1308:
1309: g.setColor(light);
1310: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
1311: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1312:
1313:
1314: g.setColor(shadow);
1315: g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
1316: g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
1317:
1318:
1319: g.setColor(shadow);
1320: g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
1321: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
1322:
1323: }
1324:
1325: g.setColor(middle);
1326: g.drawLine(x, y + h - 1, x, y + h - 1);
1327: g.drawLine(x + w - 1, y, x + w - 1, y);
1328: }
1329: else
1330: {
1331:
1332: g.setColor(MetalLookAndFeel.getControlDisabled());
1333: g.drawRect(x, y, w - 2, h - 2);
1334: }
1335: }
1336: }
1337:
1338:
1341: public static class ToolBarBorder extends AbstractBorder
1342: implements UIResource, SwingConstants
1343: {
1344:
1347: public ToolBarBorder()
1348: {
1349:
1350: }
1351:
1352:
1359: public Insets getBorderInsets(Component c)
1360: {
1361: return getBorderInsets(c, null);
1362: }
1363:
1364:
1370: public Insets getBorderInsets(Component c, Insets newInsets)
1371: {
1372: JToolBar tb = (JToolBar) c;
1373: if (tb.getOrientation() == JToolBar.HORIZONTAL)
1374: {
1375: if (newInsets == null)
1376: newInsets = new Insets(2, 16, 2, 2);
1377: else
1378: {
1379: newInsets.top = 2;
1380: newInsets.left = 16;
1381: newInsets.bottom = 2;
1382: newInsets.right = 2;
1383: }
1384: return newInsets;
1385: }
1386: else
1387: {
1388: if (newInsets == null)
1389: newInsets = new Insets(16, 2, 2, 2);
1390: else
1391: {
1392: newInsets.top = 16;
1393: newInsets.left = 2;
1394: newInsets.bottom = 2;
1395: newInsets.right = 2;
1396: }
1397: return newInsets;
1398: }
1399:
1400: }
1401:
1402:
1412: public void paintBorder(Component c, Graphics g, int x, int y, int w,
1413: int h)
1414: {
1415:
1416: JToolBar tb = (JToolBar) c;
1417: if (tb.getOrientation() == JToolBar.HORIZONTAL)
1418: {
1419: MetalUtils.fillMetalPattern(tb, g, x + 2, y + 2, x + 11, y + h - 5,
1420: MetalLookAndFeel.getControlHighlight(),
1421: MetalLookAndFeel.getControlDarkShadow());
1422: }
1423: else
1424: {
1425: MetalUtils.fillMetalPattern(tb, g, x + 2, y + 2, x + w - 5, y + 11,
1426: MetalLookAndFeel.getControlHighlight(),
1427: MetalLookAndFeel.getControlDarkShadow());
1428: }
1429: }
1430:
1431: }
1432:
1433:
1438: public static class TableHeaderBorder extends AbstractBorder
1439: {
1440:
1443:
1444:
1445:
1446: protected Insets editorBorderInsets;
1447:
1448:
1451: public TableHeaderBorder()
1452: {
1453: editorBorderInsets = new Insets(1, 1, 1, 1);
1454: }
1455:
1456:
1461: public Insets getBorderInsets(Component c)
1462: {
1463: return editorBorderInsets;
1464: }
1465:
1466:
1476: public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
1477: {
1478: Color dark = MetalLookAndFeel.getControlDarkShadow();
1479: Color light = MetalLookAndFeel.getWhite();
1480: Color old = g.getColor();
1481: g.setColor(light);
1482: g.drawLine(x, y, x + w - 2, y);
1483: g.drawLine(x, y, x, y + h - 2);
1484: g.setColor(dark);
1485: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
1486: g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
1487: g.setColor(old);
1488: }
1489: }
1490:
1491:
1496: public static Border getButtonBorder()
1497: {
1498: if (buttonBorder == null)
1499: {
1500: Border outer = new ButtonBorder();
1501: Border inner = getMarginBorder();
1502: buttonBorder = new BorderUIResource.CompoundBorderUIResource(outer,
1503: inner);
1504: }
1505: return buttonBorder;
1506: }
1507:
1508:
1515: public static Border getToggleButtonBorder()
1516: {
1517: if (toggleButtonBorder == null)
1518: {
1519: Border outer = new ToggleButtonBorder();
1520: Border inner = getMarginBorder();
1521: toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource(
1522: outer, inner);
1523: }
1524: return toggleButtonBorder;
1525: }
1526:
1527:
1535: public static Border getDesktopIconBorder()
1536: {
1537: if (desktopIconBorder == null)
1538: desktopIconBorder = new DesktopIconBorder();
1539: return desktopIconBorder;
1540: }
1541:
1542:
1549: public static Border getTextFieldBorder()
1550: {
1551: if (textFieldBorder == null)
1552: {
1553: Border inner = getMarginBorder();
1554: Border outer = new TextFieldBorder();
1555: textFieldBorder =
1556: new BorderUIResource.CompoundBorderUIResource(outer, inner);
1557: }
1558: return textFieldBorder;
1559: }
1560:
1561:
1569: public static Border getTextBorder()
1570: {
1571: if (textBorder == null)
1572: {
1573: Border inner = getMarginBorder();
1574: Border outer = new Flush3DBorder();
1575: textBorder =
1576: new BorderUIResource.CompoundBorderUIResource(outer, inner);
1577: }
1578: return textBorder;
1579: }
1580:
1581:
1586: static Border getToolbarButtonBorder()
1587: {
1588: if (toolbarButtonBorder == null)
1589: {
1590: Border outer = new ButtonBorder();
1591: Border inner = new RolloverMarginBorder();
1592: toolbarButtonBorder = new CompoundBorder(outer, inner);
1593: }
1594: return toolbarButtonBorder;
1595: }
1596:
1597:
1602: static Border getMarginBorder()
1603: {
1604: if (marginBorder == null)
1605: marginBorder = new BasicBorders.MarginBorder();
1606: return marginBorder;
1607: }
1608:
1609:
1614: static Border getRolloverBorder()
1615: {
1616: if (rolloverBorder == null)
1617: {
1618: Border outer = new MetalBorders.RolloverButtonBorder();
1619: Border inner = MetalBorders.getMarginBorder();
1620: rolloverBorder = new BorderUIResource.CompoundBorderUIResource(outer,
1621: inner);
1622: }
1623: return rolloverBorder;
1624: }
1625:
1626: }