1 7 8 package javax.swing.plaf; 9 10 import java.awt.Component ; 11 import java.awt.Insets ; 12 import java.awt.Color ; 13 import java.awt.Font ; 14 import java.awt.Graphics ; 15 import java.io.Serializable ; 16 17 import javax.swing.BorderFactory ; 18 import javax.swing.border.*; 19 import javax.swing.Icon ; 20 import javax.swing.plaf.UIResource ; 21 22 23 45 public class BorderUIResource implements Border, UIResource , Serializable 46 { 47 static Border etched; 48 static Border loweredBevel; 49 static Border raisedBevel; 50 static Border blackLine; 51 52 public static Border getEtchedBorderUIResource() { 53 if (etched == null) { 54 etched = new EtchedBorderUIResource(); 55 } 56 return etched; 57 } 58 59 public static Border getLoweredBevelBorderUIResource() { 60 if (loweredBevel == null) { 61 loweredBevel = new BevelBorderUIResource(BevelBorder.LOWERED); 62 } 63 return loweredBevel; 64 } 65 66 public static Border getRaisedBevelBorderUIResource() { 67 if (raisedBevel == null) { 68 raisedBevel = new BevelBorderUIResource(BevelBorder.RAISED); 69 } 70 return raisedBevel; 71 } 72 73 public static Border getBlackLineBorderUIResource() { 74 if (blackLine == null) { 75 blackLine = new LineBorderUIResource(Color.black); 76 } 77 return blackLine; 78 } 79 80 private Border delegate; 81 82 87 public BorderUIResource(Border delegate) { 88 if (delegate == null) { 89 throw new IllegalArgumentException ("null border delegate argument"); 90 } 91 this.delegate = delegate; 92 } 93 94 public void paintBorder(Component c, Graphics g, int x, int y, 95 int width, int height) { 96 delegate.paintBorder(c, g, x, y, width, height); 97 } 98 99 public Insets getBorderInsets(Component c) { 100 return delegate.getBorderInsets(c); 101 } 102 103 public boolean isBorderOpaque() { 104 return delegate.isBorderOpaque(); 105 } 106 107 public static class CompoundBorderUIResource extends CompoundBorder implements UIResource { 108 public CompoundBorderUIResource(Border outsideBorder, Border insideBorder) { 109 super(outsideBorder, insideBorder); 110 } 111 112 } 113 114 public static class EmptyBorderUIResource extends EmptyBorder implements UIResource { 115 116 public EmptyBorderUIResource(int top, int left, int bottom, int right) { 117 super(top, left, bottom, right); 118 } 119 public EmptyBorderUIResource(Insets insets) { 120 super(insets); 121 } 122 } 123 124 public static class LineBorderUIResource extends LineBorder implements UIResource { 125 126 public LineBorderUIResource(Color color) { 127 super(color); 128 } 129 130 public LineBorderUIResource(Color color, int thickness) { 131 super(color, thickness); 132 } 133 } 134 135 136 public static class BevelBorderUIResource extends BevelBorder implements UIResource { 137 138 public BevelBorderUIResource(int bevelType) { 139 super(bevelType); 140 } 141 142 public BevelBorderUIResource(int bevelType, Color highlight, Color shadow) { 143 super(bevelType, highlight, shadow); 144 } 145 146 public BevelBorderUIResource(int bevelType, 147 Color highlightOuter, Color highlightInner, 148 Color shadowOuter, Color shadowInner) { 149 super(bevelType, highlightOuter, highlightInner, shadowOuter, shadowInner); 150 } 151 } 152 153 public static class EtchedBorderUIResource extends EtchedBorder implements UIResource { 154 155 public EtchedBorderUIResource() { 156 super(); 157 } 158 159 public EtchedBorderUIResource(int etchType) { 160 super(etchType); 161 } 162 163 public EtchedBorderUIResource(Color highlight, Color shadow) { 164 super(highlight, shadow); 165 } 166 167 public EtchedBorderUIResource(int etchType, Color highlight, Color shadow) { 168 super(etchType, highlight, shadow); 169 } 170 } 171 172 public static class MatteBorderUIResource extends MatteBorder implements UIResource { 173 174 public MatteBorderUIResource(int top, int left, int bottom, int right, 175 Color color) { 176 super(top, left, bottom, right, color); 177 } 178 179 public MatteBorderUIResource(int top, int left, int bottom, int right, 180 Icon tileIcon) { 181 super(top, left, bottom, right, tileIcon); 182 } 183 184 public MatteBorderUIResource(Icon tileIcon) { 185 super(tileIcon); 186 } 187 } 188 189 public static class TitledBorderUIResource extends TitledBorder implements UIResource { 190 191 public TitledBorderUIResource(String title) { 192 super(title); 193 } 194 195 public TitledBorderUIResource(Border border) { 196 super(border); 197 } 198 199 public TitledBorderUIResource(Border border, String title) { 200 super(border, title); 201 } 202 203 public TitledBorderUIResource(Border border, 204 String title, 205 int titleJustification, 206 int titlePosition) { 207 super(border, title, titleJustification, titlePosition); 208 } 209 210 public TitledBorderUIResource(Border border, 211 String title, 212 int titleJustification, 213 int titlePosition, 214 Font titleFont) { 215 super(border, title, titleJustification, titlePosition, titleFont); 216 } 217 218 public TitledBorderUIResource(Border border, 219 String title, 220 int titleJustification, 221 int titlePosition, 222 Font titleFont, 223 Color titleColor) { 224 super(border, title, titleJustification, titlePosition, titleFont, titleColor); 225 } 226 } 227 228 } 229 | Popular Tags |