1. /*
  2. * @(#)EmptyBorder.java 1.20 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.border;
  8. import java.awt.Graphics;
  9. import java.awt.Insets;
  10. import java.awt.Rectangle;
  11. import java.awt.Component;
  12. import java.io.Serializable;
  13. /**
  14. * A class which provides an empty, transparent border which
  15. * takes up space but does no drawing.
  16. * <p>
  17. * <strong>Warning:</strong>
  18. * Serialized objects of this class will not be compatible with
  19. * future Swing releases. The current serialization support is appropriate
  20. * for short term storage or RMI between applications running the same
  21. * version of Swing. A future release of Swing will provide support for
  22. * long term persistence.
  23. *
  24. * @version 1.20 11/29/01
  25. * @author David Kloba
  26. */
  27. public class EmptyBorder extends AbstractBorder implements Serializable
  28. {
  29. protected int left, right, top, bottom;
  30. /**
  31. * Creates an empty border with the specified insets.
  32. * @param top the top inset of the border
  33. * @param left the left inset of the border
  34. * @param bottom the bottom inset of the border
  35. * @param right the right inset of the border
  36. */
  37. public EmptyBorder(int top, int left, int bottom, int right) {
  38. this.top = top;
  39. this.right = right;
  40. this.bottom = bottom;
  41. this.left = left;
  42. }
  43. /**
  44. * Creates an empty border with the specified insets.
  45. * @param insets the insets of the border
  46. */
  47. public EmptyBorder(Insets insets) {
  48. this.top = insets.top;
  49. this.right = insets.right;
  50. this.bottom = insets.bottom;
  51. this.left = insets.left;
  52. }
  53. /**
  54. * Does no drawing by default.
  55. */
  56. public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  57. }
  58. /**
  59. * Returns the insets of the border.
  60. * @param c the component for which this border insets value applies
  61. */
  62. public Insets getBorderInsets(Component c) {
  63. return new Insets(top, left, bottom, right);
  64. }
  65. /**
  66. * Reinitialize the insets parameter with this Border's current Insets.
  67. * @param c the component for which this border insets value applies
  68. * @param insets the object to be reinitialized
  69. */
  70. public Insets getBorderInsets(Component c, Insets insets) {
  71. insets.left = left;
  72. insets.top = top;
  73. insets.right = right;
  74. insets.bottom = bottom;
  75. return insets;
  76. }
  77. /**
  78. * Returns whether or not the border is opaque.
  79. * Returns false by default.
  80. */
  81. public boolean isBorderOpaque() { return false; }
  82. }