1. /*
  2. * @(#)EmptyBorder.java 1.25 03/01/23
  3. *
  4. * Copyright 2003 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
  20. * appropriate for short term storage or RMI between applications running
  21. * the same version of Swing. As of 1.4, support for long term storage
  22. * of all JavaBeans<sup><font size="-2">TM</font></sup>
  23. * has been added to the <code>java.beans</code> package.
  24. * Please see {@link java.beans.XMLEncoder}.
  25. *
  26. * @version 1.25 01/23/03
  27. * @author David Kloba
  28. */
  29. public class EmptyBorder extends AbstractBorder implements Serializable
  30. {
  31. protected int left, right, top, bottom;
  32. /**
  33. * Creates an empty border with the specified insets.
  34. * @param top the top inset of the border
  35. * @param left the left inset of the border
  36. * @param bottom the bottom inset of the border
  37. * @param right the right inset of the border
  38. */
  39. public EmptyBorder(int top, int left, int bottom, int right) {
  40. this.top = top;
  41. this.right = right;
  42. this.bottom = bottom;
  43. this.left = left;
  44. }
  45. /**
  46. * Creates an empty border with the specified insets.
  47. * @param borderInsets the insets of the border
  48. */
  49. public EmptyBorder(Insets borderInsets) {
  50. this.top = borderInsets.top;
  51. this.right = borderInsets.right;
  52. this.bottom = borderInsets.bottom;
  53. this.left = borderInsets.left;
  54. }
  55. /**
  56. * Does no drawing by default.
  57. */
  58. public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  59. }
  60. /**
  61. * Returns the insets of the border.
  62. * @param c the component for which this border insets value applies
  63. */
  64. public Insets getBorderInsets(Component c) {
  65. return getBorderInsets();
  66. }
  67. /**
  68. * Reinitialize the insets parameter with this Border's current Insets.
  69. * @param c the component for which this border insets value applies
  70. * @param insets the object to be reinitialized
  71. */
  72. public Insets getBorderInsets(Component c, Insets insets) {
  73. insets.left = left;
  74. insets.top = top;
  75. insets.right = right;
  76. insets.bottom = bottom;
  77. return insets;
  78. }
  79. /**
  80. * Returns the insets of the border.
  81. */
  82. public Insets getBorderInsets() {
  83. return new Insets(top, left, bottom, right);
  84. }
  85. /**
  86. * Returns whether or not the border is opaque.
  87. * Returns false by default.
  88. */
  89. public boolean isBorderOpaque() { return false; }
  90. }