1 7 8 9 package javax.swing; 10 11 import java.awt.*; 12 import java.awt.event.*; 13 import java.beans.PropertyChangeListener ; 14 import java.util.Locale ; 15 import java.io.Serializable ; 16 import javax.accessibility.*; 17 18 62 public class Box extends JComponent implements Accessible { 63 64 76 public Box(int axis) { 77 super(); 78 super.setLayout(new BoxLayout (this, axis)); 79 } 80 81 93 public static Box createHorizontalBox() { 94 return new Box (BoxLayout.X_AXIS); 95 } 96 97 109 public static Box createVerticalBox() { 110 return new Box (BoxLayout.Y_AXIS); 111 } 112 113 123 public static Component createRigidArea(Dimension d) { 124 return new Filler(d, d, d); 125 } 126 127 146 public static Component createHorizontalStrut(int width) { 147 return new Filler(new Dimension(width,0), new Dimension(width,0), 148 new Dimension(width, Short.MAX_VALUE)); 149 } 150 151 170 public static Component createVerticalStrut(int height) { 171 return new Filler(new Dimension(0,height), new Dimension(0,height), 172 new Dimension(Short.MAX_VALUE, height)); 173 } 174 175 219 public static Component createGlue() { 220 return new Filler(new Dimension(0,0), new Dimension(0,0), 221 new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); 222 } 223 224 229 public static Component createHorizontalGlue() { 230 return new Filler(new Dimension(0,0), new Dimension(0,0), 231 new Dimension(Short.MAX_VALUE, 0)); 232 } 233 234 239 public static Component createVerticalGlue() { 240 return new Filler(new Dimension(0,0), new Dimension(0,0), 241 new Dimension(0, Short.MAX_VALUE)); 242 } 243 244 249 public void setLayout(LayoutManager l) { 250 throw new AWTError("Illegal request"); 251 } 252 253 254 267 public static class Filler extends JComponent implements Accessible { 268 269 276 public Filler(Dimension min, Dimension pref, Dimension max) { 277 reqMin = min; 278 reqPref = pref; 279 reqMax = max; 280 } 281 282 291 public void changeShape(Dimension min, Dimension pref, Dimension max) { 292 reqMin = min; 293 reqPref = pref; 294 reqMax = max; 295 invalidate(); 296 } 297 298 300 305 public Dimension getMinimumSize() { 306 return reqMin; 307 } 308 309 314 public Dimension getPreferredSize() { 315 return reqPref; 316 } 317 318 323 public Dimension getMaximumSize() { 324 return reqMax; 325 } 326 327 329 private Dimension reqMin; 330 private Dimension reqPref; 331 private Dimension reqMax; 332 333 337 340 protected AccessibleContext accessibleContext = null; 341 342 351 public AccessibleContext getAccessibleContext() { 352 if (accessibleContext == null) { 353 accessibleContext = new AccessibleBoxFiller(); 354 } 355 return accessibleContext; 356 } 357 358 362 protected class AccessibleBoxFiller extends AccessibleAWTComponent { 363 372 public AccessibleRole getAccessibleRole() { 373 return AccessibleRole.FILLER; 374 } 375 } 376 } 377 378 382 385 protected AccessibleContext accessibleContext = null; 386 387 396 public AccessibleContext getAccessibleContext() { 397 if (accessibleContext == null) { 398 accessibleContext = new AccessibleBox(); 399 } 400 return accessibleContext; 401 } 402 403 407 protected class AccessibleBox extends AccessibleAWTContainer { 408 417 public AccessibleRole getAccessibleRole() { 418 return AccessibleRole.FILLER; 419 } 420 } } 422 | Popular Tags |