|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--sunw.demo.misc.Voter
A simple Java Bean that handles constrained property PropertyChange events by unconditionally vetoing or accepting all proposed changes. It can be used with the JellyBean, which fires vetoable PropertyChange events, to demonstrate constratined properties. It's easy to experiment with connecting constratined properties to Voter objects with the BeanBox. To do so programatically one would write:
import sunw.demo.jelly.JellyBean; import sunw.demo.misc.Voter; import java.beans.*; public class DemoVoter { JellyBean bean = new JellyBean(); Voter voter = new Voter(); VetoableChangeAdapter adapter = new VetoableChangeAdapter(); DemoVoter() { bean.addVetoableChangeListener(adapter); try { bean.setPriceInCents(123); } catch (PropertyVetoException e) { System.err.println("Vetoed: " + e); } } class VetoableChangeAdapter implements VetoableChangeListener { public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException { voter.vetoableChange(e); } } public static void main(String[] argv) { new DemoVoter(); } }In the example above the nested adapter calls Voter.vetoable change each time a constrained bean property is set. In this case the constrained property is "priceInCents".
JellyBean
, Serialized FormFields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Constructor Summary | |
Voter()
Construct a Voter that, by default, vetos all proposed PropertyChange events. |
Method Summary | |
java.awt.Dimension |
getPreferredSize()
|
boolean |
getVetoAll()
If true, veto all proposed changes, otherwise accept them. |
void |
paint(java.awt.Graphics g)
|
void |
setVetoAll(boolean x)
If true, veto all proposed changes, otherwise accept them. |
void |
vetoableChange(java.beans.PropertyChangeEvent x)
The PropertyChangeEvent handler method. |
Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addNotify,
addPropertyChangeListener,
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,
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 |
public Voter()
Method Detail |
public void setVetoAll(boolean x)
getVetoAll()
,
vetoableChange(java.beans.PropertyChangeEvent)
public boolean getVetoAll()
setVetoAll(boolean)
public void vetoableChange(java.beans.PropertyChangeEvent x) throws java.beans.PropertyVetoException
setVetoAll(boolean)
public java.awt.Dimension getPreferredSize()
public void paint(java.awt.Graphics g)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |