All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sunw.demo.buttons.OurButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----sunw.demo.buttons.OurButton

public class OurButton
extends Component
implements Serializable, MouseListener, MouseMotionListener
A simple Java Beans button. OurButton is a "from-scratch" lightweight AWT component. It's a good example of how to implement bound properties and support for event listeners. Parts of the source are derived from sun.awt.tiny.TinyButtonPeer.


Constructor Index

 o OurButton()
Constructs a Button with the a default label.
 o OurButton(String)
Constructs a Button with the specified label.

Method Index

 o addActionListener(ActionListener)
The specified ActionListeners actionPerformed method will be called each time the button is clicked.
 o addPropertyChangeListener(PropertyChangeListener)
The specified PropertyChangeListeners propertyChange method will be called each time the value of any bound property is changed.
 o fireAction()
This method has the same effect as pressing the button.
 o getDebug()
Returns true if debugging output is enabled.
 o getFontSize()
Return the current font point size.
 o getLabel()
Returns the buttons label.
 o getMinimumSize()
 o getPreferredSize()
 o isLargeFont()
Returns true if the font is "large" in the sense defined by setLargeFont.
 o minimumSize()
Deprecated.
 o mouseClicked(MouseEvent)
 o mouseDragged(MouseEvent)
 o mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
 o mouseMoved(MouseEvent)
 o mousePressed(MouseEvent)
 o mouseReleased(MouseEvent)
 o paint(Graphics)
Paint the button: the label is centered in both dimensions.
 o preferredSize()
Deprecated.
 o removeActionListener(ActionListener)
Remove this ActionListener from the buttons internal list.
 o removePropertyChangeListener(PropertyChangeListener)
Remove this PropertyChangeListener from the buttons internal list.
 o setBackground(Color)
Set the color the buttons background is drawn with.
 o setDebug(boolean)
Enable debugging output.
 o setFont(Font)
Set the current font and change its size to fit.
 o setFontSize(int)
Set the point size of the current font.
 o setForeground(Color)
Set the color the buttons label is drawn with.
 o setLabel(String)
Set the buttons label and change it's size to fit.
 o setLargeFont(boolean)
Set the font size to 18 if true, 12 otherwise.

Constructors

 o OurButton
 public OurButton()
Constructs a Button with the a default label.

 o OurButton
 public OurButton(String label)
Constructs a Button with the specified label.

Parameters:
label - the label of the button

Methods

 o paint
 public synchronized void paint(Graphics g)
Paint the button: the label is centered in both dimensions.

Overrides:
paint in class Component
 o mouseClicked
 public void mouseClicked(MouseEvent evt)
 o mousePressed
 public void mousePressed(MouseEvent evt)
 o mouseReleased
 public void mouseReleased(MouseEvent evt)
 o mouseEntered
 public void mouseEntered(MouseEvent evt)
 o mouseExited
 public void mouseExited(MouseEvent evt)
 o mouseDragged
 public void mouseDragged(MouseEvent evt)
 o mouseMoved
 public void mouseMoved(MouseEvent evt)
 o addActionListener
 public synchronized void addActionListener(ActionListener l)
The specified ActionListeners actionPerformed method will be called each time the button is clicked. The ActionListener object is added to a list of ActionListeners managed by this button, it can be removed with removeActionListener. Note: the JavaBeans specification does not require ActionListeners to run in any particular order.

Parameters:
l - the ActionListener
See Also:
removeActionListener
 o removeActionListener
 public synchronized void removeActionListener(ActionListener l)
Remove this ActionListener from the buttons internal list. If the ActionListener isn't on the list, silently do nothing.

Parameters:
l - the ActionListener
See Also:
addActionListener
 o addPropertyChangeListener
 public void addPropertyChangeListener(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 this button, it can be removed with removePropertyChangeListener. Note: the JavaBeans specification does not require PropertyChangeListeners to run in any particular order.

Parameters:
l - the PropertyChangeListener
See Also:
removePropertyChangeListener
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener l)
Remove this PropertyChangeListener from the buttons internal list. If the PropertyChangeListener isn't on the list, silently do nothing.

Parameters:
l - the PropertyChangeListener
See Also:
addPropertyChangeListener
 o fireAction
 public void fireAction()
This method has the same effect as pressing the button.

See Also:
addActionListener
 o setDebug
 public void setDebug(boolean x)
Enable debugging output. Currently a message is printed each time the button is clicked. This is a bound property.

See Also:
getDebug, addPropertyChangeListener
 o getDebug
 public boolean getDebug()
Returns true if debugging output is enabled.

See Also:
setDebug
 o setLargeFont
 public void setLargeFont(boolean b)
Set the font size to 18 if true, 12 otherwise. This property overrides the value specified with setFontSize. This is a bound property.

See Also:
isLargeFont, addPropertyChangeListener
 o isLargeFont
 public boolean isLargeFont()
Returns true if the font is "large" in the sense defined by setLargeFont.

See Also:
setLargeFont, setFont
 o setFontSize
 public void setFontSize(int x)
Set the point size of the current font. This is a bound property.

See Also:
getFontSize, setFont, setLargeFont, addPropertyChangeListener
 o getFontSize
 public int getFontSize()
Return the current font point size.

See Also:
setFontSize
 o setFont
 public void setFont(Font f)
Set the current font and change its size to fit. This is a bound property.

Overrides:
setFont in class Component
See Also:
setFontSize, setLargeFont
 o setLabel
 public void setLabel(String newLabel)
Set the buttons label and change it's size to fit. This is a bound property.

See Also:
getLabel
 o getLabel
 public String getLabel()
Returns the buttons label.

See Also:
setLabel
 o getPreferredSize
 public Dimension getPreferredSize()
Overrides:
getPreferredSize in class Component
 o preferredSize
 public Dimension preferredSize()
Note: preferredSize() is deprecated. provided for backward compatibility with old layout managers.

Overrides:
preferredSize in class Component
 o getMinimumSize
 public Dimension getMinimumSize()
Overrides:
getMinimumSize in class Component
 o minimumSize
 public Dimension minimumSize()
Note: minimumSize() is deprecated. provided for backward compatibility with old layout managers.

Overrides:
minimumSize in class Component
 o setForeground
 public void setForeground(Color c)
Set the color the buttons label is drawn with. This is a bound property.

Overrides:
setForeground in class Component
 o setBackground
 public void setBackground(Color c)
Set the color the buttons background is drawn with. This is a bound property.

Overrides:
setBackground in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index