home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1999 February / CDW0299.iso / Demos / Cafe / Source.bin / HorizontalLine.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  2.0 KB  |  72 lines

  1. package symantec.itools.awt.shape;
  2.  
  3. import java.beans.PropertyVetoException;
  4. import java.awt.Rectangle;
  5.  
  6. //  07/30/97    LAB    Updated version to 1.1.  Line can now be 1 pixel thick if it is
  7. //                    in BEVEL_LINE or BEVEL_NONE mode.
  8. //  08/13/97    LAB    Overrode setBevelStyle to reshape the component to have a thickness
  9. //                    of two pixels if the bevel style was rasied or lowered.  Addresses Mac
  10. //                    Bug #3571
  11.  
  12. /**
  13.  * This is a horizontal line component.
  14.  * @version 1.1, July 30, 1997
  15.  * @author Symantec
  16.  */
  17. public class HorizontalLine extends Rect
  18. {
  19.     /**
  20.      * Constructs a default HorizontalLine. The line height is 2.
  21.      */
  22.     public HorizontalLine()
  23.     {
  24.         height = 2;
  25.     }
  26.  
  27.     /**
  28.      * Sets the border style of the shape.
  29.      * @see symantec.itools.awt.shape.Shape#getBevelStyle
  30.      *
  31.      * @exception PropertyVetoException
  32.      * if the specified property value is unacceptable
  33.      */
  34.     public void setBevelStyle(int s) throws PropertyVetoException
  35.     {
  36.         if(style != s)
  37.         {
  38.             super.setBevelStyle(s);
  39.             Rectangle r = getBounds();
  40.  
  41.             reshape(r.x, r.y, r.width, r.height == 1 ? 1 : 2);
  42.             validate();
  43.         }
  44.     }
  45.     /**
  46.      * Moves and/or resizes this component.
  47.      * This is a standard Java AWT method which gets called to move and/or
  48.      * resize this component. Components that are in containers with layout
  49.      * managers should not call this method, but rely on the layout manager
  50.      * instead.
  51.      *
  52.      * @param x horizontal position in the parent's coordinate space
  53.      * @param y vertical position in the parent's coordinate space
  54.      * @param width the new width
  55.      * @param height the new height
  56.      */
  57.     public void reshape(int x, int y, int width, int height)
  58.     {
  59.         this.width = width;
  60.  
  61.         //Allow a 1 pixel height if the bevel style is line or none.
  62.         if (height == 1 && (style == BEVEL_LINE || style == BEVEL_NONE))
  63.             this.height = 1;
  64.         else
  65.             this.height = 2;
  66.  
  67.         super.reshape(x, y, width, this.height);
  68.     }
  69.  
  70. }
  71.  
  72.