All Packages  This Package  Class Hierarchy  Class Search  Index

Class aima.examples.OurButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----aima.examples.OurButton

A simple Java Beans button. OurButton is a "from-scratch" GUI component that's derived from Canvas. 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.tint.TinyButtonPeer.


public class  OurButton
     extends java.awt.Canvas
     implements java.io.Serializable, 
                java.awt.event.MouseListener, 
                java.awt.event.MouseMotionListener
{
          // Constructors 2
     public OurButton();
     public OurButton(String);

          // Methods 28
     public synchronized void addActionListener(ActionListener);
     public void addPropertyChangeListener(PropertyChangeListener);
     public void fireAction();
     public boolean getDebug();
     public int getFontSize();
     public String getLabel();
     public Dimension getMinimumSize();
     public Dimension getPreferredSize();
     public boolean isLargeFont();
     public Dimension minimumSize();
     public void mouseClicked(MouseEvent);
     public void mouseDragged(MouseEvent);
     public void mouseEntered(MouseEvent);
     public void mouseExited(MouseEvent);
     public void mouseMoved(MouseEvent);
     public void mousePressed(MouseEvent);
     public void mouseReleased(MouseEvent);
     public synchronized void paint(Graphics);
     public Dimension preferredSize();
     public synchronized void removeActionListener(ActionListener);
     public void removePropertyChangeListener(PropertyChangeListener);
     public void setBackground(Color);
     public void setDebug(boolean);
     public void setFont(Font);
     public void setFontSize(int);
     public void setForeground(Color);
     public void setLabel(String);
     public void setLargeFont(boolean);
}



Constructors


OurButton

   public OurButton() 

Constructs a Button with the a default label.



OurButton

   public OurButton(String label) 

Constructs a Button with the specified label.

Parameter Description
label the label of the button




Methods


paint

   public synchronized void paint(Graphics g) 

Paint the button: the label is centered in both dimensions.

Overrides:
paint in class Canvas


mouseClicked

   public void mouseClicked(MouseEvent evt) 
Implements:
mouseClicked in interface MouseListener


mousePressed

   public void mousePressed(MouseEvent evt) 
Implements:
mousePressed in interface MouseListener


mouseReleased

   public void mouseReleased(MouseEvent evt) 
Implements:
mouseReleased in interface MouseListener


mouseEntered

   public void mouseEntered(MouseEvent evt) 
Implements:
mouseEntered in interface MouseListener


mouseExited

   public void mouseExited(MouseEvent evt) 
Implements:
mouseExited in interface MouseListener


mouseDragged

   public void mouseDragged(MouseEvent evt) 
Implements:
mouseDragged in interface MouseMotionListener


mouseMoved

   public void mouseMoved(MouseEvent evt) 
Implements:
mouseMoved in interface MouseMotionListener


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.

Parameter Description
l the ActionListener

See Also: removeActionListener



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.

Parameter Description
l the ActionListener

See Also: addActionListener



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.

Parameter Description
l the PropertyChangeListener

See Also: removePropertyChangeListener



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.

Parameter Description
l the PropertyChangeListener

See Also: addPropertyChangeListener



fireAction

   public void fireAction() 

This method has the same effect as pressing the button.

See Also: addActionListener



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



getDebug

   public boolean getDebug() 

Returns true if debugging output is enabled.

See Also: setDebug



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



isLargeFont

   public boolean isLargeFont() 

Returns true if the font is "large" in the sense defined by setLargeFont.

See Also: setLargeFont, setFont



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



getFontSize

   public int getFontSize() 

Return the current font point size.

See Also: setFontSize



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



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



getLabel

   public String getLabel() 

Returns the buttons label.

See Also: setLabel



getPreferredSize

   public Dimension getPreferredSize() 
Overrides:
getPreferredSize in class Component


preferredSize

   public Dimension preferredSize() 
Note: preferredSize() is deprecatedprovided for backward compatibility with old layout managers.

Overrides:
preferredSize in class Component


getMinimumSize

   public Dimension getMinimumSize() 
Overrides:
getMinimumSize in class Component


minimumSize

   public Dimension minimumSize() 
Note: minimumSize() is deprecatedprovided for backward compatibility with old layout managers.

Overrides:
minimumSize in class Component


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


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  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4