home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / Source.bin / LabelButton.java < prev    next >
Encoding:
Java Source  |  1998-09-14  |  22.2 KB  |  697 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Dimension;
  5. import java.awt.FontMetrics;
  6. import java.awt.Font;
  7. import java.awt.Graphics;
  8. import java.beans.PropertyVetoException;
  9. import java.beans.PropertyChangeListener;
  10. import java.beans.VetoableChangeListener;
  11. import java.beans.PropertyChangeEvent;
  12. import java.lang.IllegalArgumentException;
  13. import symantec.itools.awt.util.ColorUtils;
  14. import java.util.ResourceBundle;
  15.  
  16. //     01/29/97    TWB    Integrated changes from Macintosh
  17. //     02/27/97    RKM    Merged in Scott's changes
  18. //     05/31/97    LAB Updated to Java 1.1
  19. //     07/09/97    LAB Changed the way the button is drawn.  Now it uses the offscreen
  20. //                    Image.  Cleaned up the drawing code to be more universal.
  21. //                    Added pressed and disabled colors for the text durring those states.
  22. //                    Added a VerticalAlignStyle property to align the text vertically.
  23. //                    Added a preferedSize() method that works.
  24. //                    Removed BevelStyle, Show/HideLabel, and BorderIndent.
  25. //                    No longer overrides setFont(), minimumSize(), or paint().
  26. //    07/13/97    RKM    Fixed misspelling of prefered
  27. //     07/20/97    LAB    Fixed a logic problem when testing for null strings.
  28. //  07/23/97    CAR changed getPreferredSize
  29. //  07/23/97    CAR marked field transient as needed, inner classes implement java.io.Serializable
  30. //     08/05/97    LAB    Added a call to clipRect in the updateButtonImage method to clip subsequent
  31. //                    drawings to the internal button area (sans border and bevel). This should be
  32. //                    removed when the VM interprets the base class' call to clipRect correctly.
  33. //     08/06/97    LAB    Removed the call to clipRect; now uses the base classes buttonImageGraphics
  34. //                    Graphics to draw with, which inherits the clipping.
  35. //  08/19/97    CAR commented out duplicate call to setVerticalAlignStyle in constructor
  36.  
  37. /**
  38.  * LabelButton is a 3D looking button that displays a string on it's face.
  39.  * Use an LabelButton to:
  40.  * <UL>
  41.  * <DT>╖ Display text in a 3D looking button.</DT>
  42.  * <DT>╖ Generate a train of action events while the user presses the button.</DT>
  43.  * </UL>
  44.  * <p>
  45.  * @version 1.1, July 8, 1997
  46.  * @author  Symantec
  47.  */
  48. public class LabelButton extends ButtonBase implements AlignStyle
  49. {
  50.     /**
  51.      * Defines the "top" label text alignment style.
  52.      */
  53.     public static final int ALIGN_TOP = 0;
  54.  
  55.     /**
  56.      * Defines the "bottom" label text alignment style.
  57.      */
  58.     public static final int ALIGN_BOTTOM = 2;
  59.  
  60.     /**
  61.      * Constructs an empty LabelButton with center aligned black text.
  62.      */
  63.     public LabelButton()
  64.     {
  65.         this("", ALIGN_CENTERED, ALIGN_CENTERED, Color.black);
  66.     }
  67.  
  68.     /**
  69.      * Constructs a LabelButton with the specified centered, black text.
  70.      * @param sText the label text
  71.      */
  72.     public LabelButton(String sText)
  73.     {
  74.         this(sText, ALIGN_CENTERED, ALIGN_CENTERED, Color.black);
  75.     }
  76.  
  77.     /**
  78.      * Constructs a LabelButton with the specified centered text,
  79.      * with the specified color.
  80.      * @param sText the label text
  81.      */
  82.     public LabelButton(String sText, Color color)
  83.     {
  84.         this(sText, ALIGN_CENTERED, ALIGN_CENTERED, color);
  85.     }
  86.  
  87.     /**
  88.      * Constructs a LabelButton with the specified vertically centered black text, and the
  89.      * specified horizontal text alignment style.
  90.      * @param sText the label text
  91.      * @param alignStyle the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  92.      * @see AlignStyle#ALIGN_LEFT
  93.      * @see AlignStyle#ALIGN_CENTERED
  94.      * @see AlignStyle#ALIGN_RIGHT
  95.      */
  96.     public LabelButton(String sText, int alignStyle)
  97.     {
  98.         this(sText, alignStyle, ALIGN_CENTERED, Color.black);
  99.     }
  100.  
  101.     /**
  102.      * Constructs a LabelButton with the specified attributes.
  103.      * @param sText the label text
  104.      * @param hAlignStyle the text horizontal alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  105.      * @param vAlignStyle the text vertical alignment style: ALIGN_TOP, ALIGN_CENTERED, or ALIGN_BOTTOM
  106.      * @param color the label text color
  107.      * @see AlignStyle#ALIGN_LEFT
  108.      * @see AlignStyle#ALIGN_CENTERED
  109.      * @see AlignStyle#ALIGN_RIGHT
  110.      * @see #ALIGN_TOP
  111.      * @see #ALIGN_BOTTOM
  112.      */
  113.     public LabelButton(String sText, int hAlignStyle, int vAlignStyle, Color color)
  114.     {
  115.         try
  116.         {
  117.             setText(sText);
  118.             setTextColor(color);
  119.             setAlignStyle(hAlignStyle);
  120.             setVerticalAlignStyle(vAlignStyle);
  121.             //setVerticalAlignStyle(ALIGN_CENTERED);
  122.         }
  123.         catch(PropertyVetoException e){}
  124.     }
  125.  
  126.     /**
  127.      * Sets the text horizontal alignment style.
  128.      * Causes the component to redraw.
  129.      * @param style the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  130.      * @see #getAlignStyle
  131.      * @see AlignStyle#ALIGN_LEFT
  132.      * @see AlignStyle#ALIGN_CENTERED
  133.      * @see AlignStyle#ALIGN_RIGHT
  134.      * @exception PropertyVetoException
  135.      * if the specified property value is unacceptable
  136.      */
  137.     public void setAlignStyle(int style) throws PropertyVetoException
  138.     {
  139.         if(hAlignStyle != style)
  140.         {
  141.             Integer oldValue = new Integer(hAlignStyle);
  142.             Integer newValue = new Integer(style);
  143.  
  144.             vetos.fireVetoableChange("AlignStyle", oldValue, newValue);
  145.  
  146.             hAlignStyle = style;
  147.             repaint();
  148.  
  149.             changes.firePropertyChange("AlignStyle", oldValue, newValue);
  150.         }
  151.     }
  152.  
  153.     /**
  154.      * Gets the current text alignment style.
  155.      * @return the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  156.      * @see #setAlignStyle
  157.      * @see AlignStyle#ALIGN_LEFT
  158.      * @see AlignStyle#ALIGN_CENTERED
  159.      * @see AlignStyle#ALIGN_RIGHT
  160.      */
  161.     public int getAlignStyle()
  162.     {
  163.         return hAlignStyle;
  164.     }
  165.  
  166.     /**
  167.      * Sets the text vertical alignment style.
  168.      * Causes the component to redraw.
  169.      * @param style the text alignment style: ALIGN_TOP, ALIGN_CENTERED, or ALIGN_BOTTOM
  170.      * @see #getVerticalAlignStyle
  171.      * @see #ALIGN_TOP
  172.      * @see AlignStyle#ALIGN_CENTERED
  173.      * @see #ALIGN_BOTTOM
  174.      * @exception PropertyVetoException
  175.      * if the specified property value is unacceptable
  176.      */
  177.     public void setVerticalAlignStyle(int style) throws PropertyVetoException
  178.     {
  179.         if(vAlignStyle != style)
  180.         {
  181.             Integer oldValue = new Integer(vAlignStyle);
  182.             Integer newValue = new Integer(style);
  183.  
  184.             vetos.fireVetoableChange("VerticalAlignStyle", oldValue, newValue);
  185.  
  186.             vAlignStyle = style;
  187.             repaint();
  188.  
  189.             changes.firePropertyChange("VerticalAlignStyle", oldValue, newValue);
  190.         }
  191.     }
  192.  
  193.     /**
  194.      * Gets the current text alignment style.
  195.      * @return the text alignment style: ALIGN_TOP, ALIGN_CENTERED, or ALIGN_BOTTOM
  196.      * @see #setVerticalAlignStyle
  197.      * @see #ALIGN_TOP
  198.      * @see AlignStyle#ALIGN_CENTERED
  199.      * @see #ALIGN_BOTTOM
  200.      */
  201.     public int getVerticalAlignStyle()
  202.     {
  203.         return vAlignStyle;
  204.     }
  205.  
  206.     /**
  207.      * Sets the label text.
  208.      * Causes the component to redraw.
  209.      * @param sText the new label text
  210.      * @see #getText
  211.      * @exception PropertyVetoException
  212.      * if the specified property value is unacceptable
  213.      */
  214.     public void setText(String sText) throws PropertyVetoException
  215.     {
  216.         if(sLabelButton == null || !sLabelButton.equals(sText))
  217.         {
  218.             String oldValue = sLabelButton == null ? null : new String(sLabelButton);
  219.  
  220.             vetos.fireVetoableChange("Text", oldValue, sText);
  221.  
  222.             sLabelButton = sText;
  223.             repaint();
  224.  
  225.             changes.firePropertyChange("Text", oldValue, sText);
  226.         }
  227.     }
  228.  
  229.     /**
  230.      * Gets the current label text.
  231.      * @return the current label text
  232.      * @see #setText
  233.      */
  234.     public String getText()
  235.     {
  236.         return sLabelButton;
  237.     }
  238.  
  239.     /**
  240.      * Sets the label text color.
  241.      * Causes the component to redraw.
  242.      * @param color the new color for the label text
  243.      * @see #getTextColor
  244.      * @exception PropertyVetoException
  245.      * if the specified property value is unacceptable
  246.      */
  247.     public void setTextColor(Color color) throws PropertyVetoException
  248.     {
  249.         if(! symantec.itools.util.GeneralUtils.objectsEqual(textColor, color))
  250.         {
  251.             Color oldValue = textColor;
  252.  
  253.             vetos.fireVetoableChange("TextColor", oldValue, color);
  254.  
  255.             textColor = color;
  256.             try
  257.             {
  258.                 disabledTextColor    = ColorUtils.lighten(textColor,    0.333);
  259.                 pressedTextColor    = ColorUtils.darken(textColor,    0.250);
  260.             }
  261.             catch (IllegalArgumentException exc) {}
  262.             repaint();
  263.  
  264.             changes.firePropertyChange("TextColor", oldValue, color);
  265.         }
  266.     }
  267.  
  268.     /**
  269.      * Gets the current label text color.
  270.      * @return the current color of the label text
  271.      * @see #setTextColor
  272.      */
  273.     public Color getTextColor()
  274.     {
  275.         return textColor;
  276.     }
  277.  
  278.     /**
  279.      * Returns the recommended dimensions to properly display this component.
  280.      * This is a standard Java AWT method which gets called to determine
  281.      * the recommended size of this component.
  282.      *
  283.      * The Dimension returned is large enough for the label and a one pixel
  284.      * space between the label and the button's bevel.
  285.      */
  286.     public Dimension getPreferredSize()
  287.     {
  288.         if(isAdded)
  289.         {
  290.             Dimension s        = size();
  291.             Graphics g        = getGraphics();
  292.             FontMetrics fm    = g.getFontMetrics();
  293.             int labelWidth    = 0;
  294.  
  295.             //Make sure we don't cause a NullPointerException when accessing the string width.
  296.             if(!(sLabelButton == null || sLabelButton.equals("")))
  297.                 labelWidth = fm.stringWidth(sLabelButton);
  298.  
  299.             if (g != null)
  300.                 g.dispose();
  301.  
  302.             return new Dimension(labelWidth + bevel + bevel + 4, fm.getAscent() + fm.getDescent() + bevel + bevel + 4);
  303.         }
  304.         return super.getPreferredSize();
  305.     }
  306.  
  307.     /**
  308.      * Tells this component that it has been added to a container.
  309.      * This is a standard Java AWT method which gets called by the AWT when
  310.      * this component is added to a container. Typically, it is used to
  311.      * create this component's peer.
  312.      *
  313.      * It has been overridden here to hook-up event listeners.
  314.      *
  315.      * @see #removeNotify
  316.      */
  317.     public synchronized void addNotify()
  318.     {
  319.         super.addNotify();
  320.         
  321.         try
  322.         {
  323.             errors = ResourceBundle.getBundle("symantec.itools.resources.ErrorsBundle");
  324.         }
  325.         catch(Throwable ex)
  326.         {
  327.             errors = new symantec.itools.resources.ErrorsBundle();
  328.         }
  329.  
  330.         //Hook up listeners
  331.         if (horizontalVeto == null)
  332.         {
  333.             horizontalVeto = new HAVeto();
  334.             addAlignStyleListener(horizontalVeto);
  335.         }
  336.         if (verticalVeto == null)
  337.         {
  338.             verticalVeto = new VAVeto();
  339.             addVerticalAlignStyleListener(verticalVeto);
  340.         }
  341.     }
  342.  
  343.     /**
  344.      * Tells this component that it is being removed from a container.
  345.      * This is a standard Java AWT method which gets called by the AWT when
  346.      * this component is removed from a container. Typically, it is used to
  347.      * destroy the peers of this component and all its subcomponents.
  348.      *
  349.      * It has been overridden here to unhook event listeners.
  350.      *
  351.      * @see #addNotify
  352.      */
  353.     public synchronized void removeNotify()
  354.     {
  355.         //Unhook listeners
  356.         if (horizontalVeto != null)
  357.         {
  358.             removeAlignStyleListener(horizontalVeto);
  359.             horizontalVeto = null;
  360.         }
  361.         if (verticalVeto != null)
  362.         {
  363.             removeVerticalAlignStyleListener(verticalVeto);
  364.             verticalVeto = null;
  365.         }
  366.  
  367.         super.removeNotify();
  368.     }
  369.  
  370.     /**
  371.      * Adds a listener for all event changes.
  372.      * @param listener the listener to add.
  373.      * @see #removePropertyChangeListener
  374.      */
  375.     public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
  376.     {
  377.         super.addPropertyChangeListener(listener);
  378.         changes.addPropertyChangeListener(listener);
  379.     }
  380.  
  381.     /**
  382.      * Removes a listener for all event changes.
  383.      * @param listener the listener to remove.
  384.      * @see #addPropertyChangeListener
  385.      */
  386.     public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
  387.     {
  388.         super.removePropertyChangeListener(listener);
  389.         changes.removePropertyChangeListener(listener);
  390.     }
  391.  
  392.     /**
  393.      * Adds a vetoable listener for all event changes.
  394.      * @param listener the listener to add.
  395.      * @see #removeVetoableChangeListener
  396.      */
  397.     public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
  398.     {
  399.         super.addVetoableChangeListener(listener);
  400.         vetos.addVetoableChangeListener(listener);
  401.     }
  402.  
  403.     /**
  404.      * Removes a vetoable listener for all event changes.
  405.      * @param listener the listener to remove.
  406.      * @see #addVetoableChangeListener
  407.      */
  408.     public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
  409.     {
  410.         super.removeVetoableChangeListener(listener);
  411.         vetos.removeVetoableChangeListener(listener);
  412.     }
  413.  
  414.     /**
  415.      * Adds a listener for the AlignStyle property changes.
  416.      * @param listener the listener to add.
  417.      * @see #removeAlignStyleChangeListener
  418.      */
  419.     public synchronized void addAlignStyleListener(PropertyChangeListener listener)
  420.     {
  421.         changes.addPropertyChangeListener("AlignStyle", listener);
  422.     }
  423.  
  424.     /**
  425.      * Removes a listener for the AlignStyle property changes.
  426.      * @param listener the listener to remove.
  427.      * @see #addAlignStyleChangeListener
  428.      */
  429.     public synchronized void removeAlignStyleListener(PropertyChangeListener listener)
  430.     {
  431.         changes.removePropertyChangeListener("AlignStyle", listener);
  432.     }
  433.  
  434.     /**
  435.      * Adds a vetoable listener for the AlignStyle property changes.
  436.      * @param listener the listener to add.
  437.      * @see #removeVetoableAlignStyleChangeListener
  438.      */
  439.     public synchronized void addAlignStyleListener(VetoableChangeListener listener)
  440.     {
  441.         vetos.addVetoableChangeListener("AlignStyle", listener);
  442.     }
  443.  
  444.     /**
  445.      * Removes a vetoable listener for the AlignStyle property changes.
  446.      * @param listener the listener to remove.
  447.      * @see #addVetoableAlignStyleChangeListener
  448.      */
  449.     public synchronized void removeAlignStyleListener(VetoableChangeListener listener)
  450.     {
  451.         vetos.removeVetoableChangeListener("AlignStyle", listener);
  452.     }
  453.  
  454.     /**
  455.      * Adds a listener for the VerticalAlignStyle property changes.
  456.      * @param listener the listener to add.
  457.      * @see #removeVerticalAlignStyleChangeListener
  458.      */
  459.     public synchronized void addVerticalAlignStyleListener(PropertyChangeListener listener)
  460.     {
  461.         changes.addPropertyChangeListener("VerticalAlignStyle", listener);
  462.     }
  463.  
  464.     /**
  465.      * Removes a listener for the VerticalAlignStyle property changes.
  466.      * @param listener the listener to remove.
  467.      * @see #addVerticalAlignStyleChangeListener
  468.      */
  469.     public synchronized void removeVerticalAlignStyleListener(PropertyChangeListener listener)
  470.     {
  471.         changes.removePropertyChangeListener("VerticalAlignStyle", listener);
  472.     }
  473.  
  474.     /**
  475.      * Adds a vetoable listener for the VerticalAlignStyle property changes.
  476.      * @param listener the listener to add.
  477.      * @see #removeVetoableVerticalAlignStyleChangeListener
  478.      */
  479.     public synchronized void addVerticalAlignStyleListener(VetoableChangeListener listener)
  480.     {
  481.         vetos.addVetoableChangeListener("VerticalAlignStyle", listener);
  482.     }
  483.  
  484.     /**
  485.      * Removes a vetoable listener for the VerticalAlignStyle property changes.
  486.      * @param listener the listener to remove.
  487.      * @see #addVetoableVerticalAlignStyleChangeListener
  488.      */
  489.     public synchronized void removeVerticalAlignStyleListener(VetoableChangeListener listener)
  490.     {
  491.         vetos.removeVetoableChangeListener("VerticalAlignStyle", listener);
  492.     }
  493.  
  494.     /**
  495.      * This is the PropertyChangeEvent handling inner class for the constrained AlignStyle property.
  496.      * Handles vetoing AlignStyles that are not valid.
  497.      */
  498.     class HAVeto implements java.beans.VetoableChangeListener, java.io.Serializable
  499.     {
  500.         /**
  501.          * This method gets called when an attempt to change the constrained AlignStyle property is made.
  502.          * Ensures the given AlignStyle is valid.
  503.          *
  504.          * @param     e a <code>PropertyChangeEvent</code> object describing the
  505.          *             event source and the property that has changed.
  506.          * @exception PropertyVetoException if the recipient wishes the property
  507.          *              change to be rolled back.
  508.          */
  509.         public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
  510.         {
  511.             int i = ((Integer)e.getNewValue()).intValue();
  512.             if (!isValidHorizontalAlignStyle(i))
  513.             {
  514.                 throw new PropertyVetoException(errors.getString("InvalidAlignStyle") + i, e);
  515.             }
  516.         }
  517.     }
  518.  
  519.     /**
  520.      * This is the PropertyChangeEvent handling inner class for the constrained VerticalAlignStyle property.
  521.      * Handles vetoing VerticalAlignStyles that are not valid.
  522.      */
  523.     class VAVeto implements java.beans.VetoableChangeListener, java.io.Serializable
  524.     {
  525.         /**
  526.          * This method gets called when an attempt to change the constrained VerticalAlignStyle property is made.
  527.          * Ensures the given AlignStyle is valid.
  528.          *
  529.          * @param     e a <code>PropertyChangeEvent</code> object describing the
  530.          *             event source and the property that has changed.
  531.          * @exception PropertyVetoException if the recipient wishes the property
  532.          *              change to be rolled back.
  533.          */
  534.         public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
  535.         {
  536.             int i = ((Integer)e.getNewValue()).intValue();
  537.             if (!isValidVerticalAlignStyle(i))
  538.             {
  539.                 throw new PropertyVetoException(errors.getString("InvalidVerticalAlignStyle") + i, e);
  540.             }
  541.         }
  542.     }
  543.  
  544.     /**
  545.      * Is the given Horizontal AlignStyle valid for this button.
  546.      * @param i the given Horizontal AlignStyle
  547.      * @return true if the given Horizontal AlignStyle is acceptable, false if not.
  548.      */
  549.     protected boolean isValidHorizontalAlignStyle(int i)
  550.     {
  551.         switch(i)
  552.         {
  553.             case ALIGN_LEFT:
  554.             case ALIGN_CENTERED:
  555.             case ALIGN_RIGHT:
  556.                 return true;
  557.             default:
  558.                 return false;
  559.         }
  560.     }
  561.  
  562.     /**
  563.      * Is the given Vertical AlignStyle valid for this button.
  564.      * @param i the given Vertical AlignStyle
  565.      * @return true if the given Vertical AlignStyle is acceptable, false if not.
  566.      */
  567.     protected boolean isValidVerticalAlignStyle(int i)
  568.     {
  569.         switch(i)
  570.         {
  571.             case ALIGN_TOP:
  572.             case ALIGN_CENTERED:
  573.             case ALIGN_BOTTOM:
  574.                 return true;
  575.             default:
  576.                 return false;
  577.         }
  578.     }
  579.  
  580.     /**
  581.      * Draws the button in the buttonImage offscreen image.
  582.      * This should only be called after the component is added to a container,
  583.      * to avoid a NullPointerException when accessing FontMetrics.
  584.      * @see symantec.itools.awt.ButtonBase#updateButtonImage
  585.      */
  586.     protected void updateButtonImage()
  587.     {
  588.         super.updateButtonImage();
  589.  
  590.         FontMetrics fm = buttonImageGraphics.getFontMetrics();
  591.         Color tempColor;
  592.         int xPos = 0;
  593.         int yPos = 0;
  594.         int labelWidth = 0;
  595.         Dimension s = size();
  596.  
  597.         //Make sure we don't cause a NullPointerException when accessing the string width.
  598.         if(!(sLabelButton == null || sLabelButton.equals("")))
  599.             labelWidth = fm.stringWidth(sLabelButton);
  600.  
  601.         if(isEnabled())
  602.         {
  603.             if(pressed)
  604.                 tempColor = pressedTextColor;
  605.             else
  606.                 tempColor = textColor;
  607.         }
  608.         else
  609.         {
  610.             tempColor = disabledTextColor;
  611.         }
  612.  
  613.  
  614.         switch(hAlignStyle)
  615.         {
  616.             case ALIGN_LEFT:
  617.                 //Align with the left edge and add a one pixel margin.
  618.                 xPos = bevel + 2;
  619.                 break;
  620.             case ALIGN_RIGHT:
  621.                 //Align with the right edge and add a one pixel margin.
  622.                 xPos = s.width - 3 - bevel - labelWidth;
  623.                break;
  624.             case ALIGN_CENTERED:
  625.                 xPos = (s.width - labelWidth) >> 1;
  626.                 break;
  627.         }
  628.  
  629.         switch(vAlignStyle)
  630.         {
  631.             case ALIGN_TOP:
  632.                 //Align with the top edge and add a one pixel margin.
  633.                 yPos = bevel + 2 + fm.getAscent();
  634.                 break;
  635.             case ALIGN_BOTTOM:
  636.                 //Align with the bottom edge and add a one pixel margin.
  637.                 yPos = s.height - 3 - bevel - fm.getDescent();
  638.                 break;
  639.             case ALIGN_CENTERED:
  640.                 yPos = (s.height + fm.getAscent()) >> 1;
  641.                 break;
  642.         }
  643.  
  644.         buttonImageGraphics.setColor(tempColor);
  645.         buttonImageGraphics.drawString(sLabelButton, xPos + pressedAdjustment, yPos + pressedAdjustment);
  646.     }
  647.  
  648.     /**
  649.      * The button label text.
  650.      */
  651.     protected String sLabelButton;
  652.     /**
  653.      * The text vertical alignment style.
  654.      * The value is one of: ALIGN_TOP, ALIGN_CENTERED, or ALIGN_BOTTOM
  655.      * @see #getVerticalAlignStyle
  656.      * @see #setVerticalAlignStyle
  657.      * @see #ALIGN_TOP
  658.      * @see AlignStyle#ALIGN_CENTERED
  659.      * @see #ALIGN_BOTTOM
  660.      */
  661.     protected int vAlignStyle;
  662.     /**
  663.      * The text horizontal alignment style.
  664.      * The value is one of: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  665.      * @see #getAlignStyle
  666.      * @see #setAlignStyle
  667.      * @see AlignStyle#ALIGN_LEFT
  668.      * @see AlignStyle#ALIGN_CENTERED
  669.      * @see AlignStyle#ALIGN_RIGHT
  670.      */
  671.     protected int hAlignStyle;
  672.     /**
  673.      * The color used for text when this component is enabled.
  674.      * @see #getTextColor
  675.      * @see #setTextColor
  676.      */
  677.     protected Color textColor            = null;
  678.     /**
  679.      * The color used for text when this component is pressed.
  680.      * This color is automatically determined.
  681.      */
  682.     protected Color pressedTextColor    = null;
  683.     /**
  684.      * The color used for text when this component is disabled.
  685.      * This color is automatically determined.
  686.      */
  687.     protected Color disabledTextColor    = null;
  688.  
  689.     transient protected ResourceBundle errors;
  690.  
  691.     private HAVeto    horizontalVeto    = null;
  692.     private VAVeto    verticalVeto    = null;
  693.     private symantec.itools.beans.VetoableChangeSupport vetos = new symantec.itools.beans.VetoableChangeSupport(this);
  694.     private symantec.itools.beans.PropertyChangeSupport changes = new symantec.itools.beans.PropertyChangeSupport(this);
  695. }
  696.  
  697.