sunw.demo.jelly
Class JellyBean

java.lang.Object
  |
  +--java.awt.Component
        |
        +--sunw.demo.jelly.JellyBean

public class JellyBean
extends java.awt.Component

A simple bean with bound properties and one constrained property. The constrained property is "priceInCents". VetoablePropertyChange listeners can reject a proposed value for this property by throwing a PropertyVetoException.

See Also:
Voter, Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
JellyBean()
          Construct a smallish JellyBean.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          The specified PropertyChangeListeners propertyChange method will be called each time the value of any bound property is changed.
 void addVetoableChangeListener(java.beans.VetoableChangeListener l)
          The specified VetoableChangeListeners vetoableChange method will be called each time the value of any constrained property is changed.
 java.awt.Color getColor()
          Returns the color that the jelly bean is rendered with.
 java.awt.Dimension getPreferredSize()
           
 int getPriceInCents()
          Returns the current price.
 void paint(java.awt.Graphics g)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove this PropertyChangeListener from the JellyBeans internal list.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener l)
          Remove this VetoableChangeListener from the JellyBeans internal list.
 void setColor(java.awt.Color newColor)
          Sets the color that the jelly bean is rendered with.
 void setPriceInCents(int newPriceInCents)
          Set the price in cents unless one of the VetoableChangeListeners throws a PropertyVetoException.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JellyBean

public JellyBean()
Construct a smallish JellyBean.
Method Detail

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Component

getColor

public java.awt.Color getColor()
Returns the color that the jelly bean is rendered with.
See Also:
setColor(java.awt.Color)

setColor

public void setColor(java.awt.Color newColor)
Sets the color that the jelly bean is rendered with. This is a bound property.
See Also:
getColor()

getPriceInCents

public int getPriceInCents()
Returns the current price.
See Also:
setPriceInCents(int)

setPriceInCents

public void setPriceInCents(int newPriceInCents)
                     throws java.beans.PropertyVetoException
Set the price in cents unless one of the VetoableChangeListeners throws a PropertyVetoException. This is a constrained property.
Throws:
java.beans.PropertyVetoException - if the proposed price was vetoed

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
The specified PropertyChangeListeners propertyChange method will be called each time the value of any bound property is changed. The PropertyListener object is addded to a list of PropertyChangeListeners managed by the JellyBean, it can be removed with removePropertyChangeListener. Note: the JavaBeans specification does not require PropertyChangeListeners to run in any particular order.
Overrides:
addPropertyChangeListener in class java.awt.Component
Parameters:
l - the PropertyChangeListener
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove this PropertyChangeListener from the JellyBeans internal list. If the PropertyChangeListener isn't on the list, silently do nothing.
Overrides:
removePropertyChangeListener in class java.awt.Component
Parameters:
l - the PropertyChangeListener
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener l)
The specified VetoableChangeListeners vetoableChange method will be called each time the value of any constrained property is changed. Currently, the only constrained property is "priceInCents". The VetoableChangeListener object is addded to a list of VetoableChangeListeners managed by the JellyBean, it can be removed with removeVetoableChangeListener. Note: the JavaBeans specification does not require VetoableChangeListeners to run in any particular order.
Parameters:
l - the VetoableChangeListener
See Also:
removeVetoableChangeListener(java.beans.VetoableChangeListener)

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener l)
Remove this VetoableChangeListener from the JellyBeans internal list. If the VetoableChangeListener isn't on the list, silently do nothing.
Parameters:
l - the VetoableChangeListener
See Also:
addVetoableChangeListener(java.beans.VetoableChangeListener)