home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / utils / buttons.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  642 b   |  37 lines

  1. // Buttons.java
  2. // 29.03.96
  3. //
  4. // A group of buttons
  5.  
  6. package cybcerone.utils;
  7.  
  8. import java.util.Vector;
  9. import java.util.Enumeration;
  10.  
  11. /**
  12.  * Searchable group of buttons.
  13.  */
  14. public class Buttons {
  15.   private Vector theButtons;
  16.  
  17.   public Buttons () {
  18.     theButtons = new Vector ();
  19.   }
  20.  
  21.   public void addButton (Button newButton) {
  22.     theButtons.addElement (newButton);
  23.   }
  24.  
  25.   public Button which (int x, int y) {
  26.     Button theButton;
  27.  
  28.     for (Enumeration e = theButtons.elements ();
  29.      e.hasMoreElements ();) {
  30.       theButton = (Button)e.nextElement ();
  31.       if (theButton.inside (x, y))
  32.     return theButton;
  33.     }
  34.     return null;
  35.   }
  36. }
  37.