home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.6 KB | 88 lines |
- // KeypadButtonGroup.java
- // 28.02.96
- //
- // a collection of KeypadButton objects
-
- package cybcerone.utils;
-
- import java.util.Vector;
- import java.util.Enumeration;
-
- class KeypadButtonGroup {
-
- private Vector buttons;
- private KeypadButton highlighted;
-
- KeypadButtonGroup () {
- buttons = new Vector ();
- }
-
- /**
- * Add a button to the group.
- */
- void add (KeypadButton newButton) {
- buttons.addElement (newButton);
- }
-
- /**
- * Which button is at (x, y)?
- */
- KeypadButton whichButton (int x, int y) {
- Enumeration e = buttons.elements ();
- KeypadButton theButton = null;
-
- while (e.hasMoreElements ()) {
- theButton = (KeypadButton)e.nextElement ();
- if (theButton.inside (x, y))
- return theButton;
- }
- return null;
- }
-
- /**
- * Which button has this value?
- */
- KeypadButton whichButton (Object value) {
- Enumeration e = buttons.elements ();
- KeypadButton theButton = null;
-
- while (e.hasMoreElements ()) {
- theButton = (KeypadButton)e.nextElement ();
- if (theButton.getValue().equals (value))
- return theButton;
- }
- return null;
- }
-
- /**
- * This is the button to highlight. Note: this doesn't draw anything,
- * it's just for later reference.
- */
- void setHighlighted (KeypadButton button) {
- highlighted = button;
- }
-
- /**
- * Which button did we highlight again?
- */
- KeypadButton getHighlighted () {
- return highlighted;
- }
-
- /**
- * Nothing's highlighted anymore.
- */
- void clearHighlighted () {
- highlighted = null;
- }
-
- /**
- * Does this group contain this button?
- */
- public boolean contains (KeypadButton button) {
- return buttons.contains (button);
- }
- }
-
-
-