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