FileDocCategorySizeDatePackage
BangBean2.javaAPI DocExample6174Mon Apr 06 18:10:22 BST 1998None

BangBean2

public class BangBean2 extends Canvas implements Serializable

Fields Summary
private int
xm
private int
ym
private int
cSize
private String
text
private int
fontSize
private Color
tColor
private Vector
actionListeners
Constructors Summary
public BangBean2()

    
    addMouseListener(new ML());
    addMouseMotionListener(new MM());
  
Methods Summary
public synchronized voidaddActionListener(java.awt.event.ActionListener l)

    actionListeners.addElement(l);
  
public synchronized java.lang.StringgetBangText()

 
    return text; 
  
public synchronized intgetCircleSize()

 
    return cSize; 
  
public synchronized intgetFontSize()

 
    return fontSize; 
  
public synchronized java.awt.ColorgetTextColor()

    return tColor; 
  
public static voidmain(java.lang.String[] args)

    BangBean2 bb = new BangBean2();
    bb.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e){
        System.out.println("ActionEvent" + e);
      }
    });
    bb.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e){
        System.out.println("BangBean2 action");
      }
    });
    bb.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e){
        System.out.println("More action");
      }
    });
    Frame aFrame = new Frame("BangBean2 Test");
    aFrame.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
    aFrame.add(bb, BorderLayout.CENTER);
    aFrame.setSize(300,300);
    aFrame.setVisible(true);
  
public voidnotifyListeners()

    ActionEvent a =
      new ActionEvent(BangBean2.this,
        ActionEvent.ACTION_PERFORMED, null);
    Vector lv = null;
    // Make a copy of the vector in case someone
    // adds a listener while we're 
    // calling listeners:
    synchronized(this) {
      lv = (Vector)actionListeners.clone();
    }
    // Call all the listener methods:
    for(int i = 0; i < lv.size(); i++) {
      ActionListener al = 
        (ActionListener)lv.elementAt(i);
      al.actionPerformed(a);
    }
  
public voidpaint(java.awt.Graphics g)

    g.setColor(Color.black);
    g.drawOval(xm - cSize/2, ym - cSize/2, 
      cSize, cSize);
  
public synchronized voidremoveActionListener(java.awt.event.ActionListener l)

    actionListeners.removeElement(l);
  
public synchronized voidsetBangText(java.lang.String newText)

    text = newText;
  
public synchronized voidsetCircleSize(int newSize)

    cSize = newSize;
  
public synchronized voidsetFontSize(int newSize)

    fontSize = newSize;
  
public synchronized voidsetTextColor(java.awt.Color newColor)

    tColor = newColor;