home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / control / urgencesbutton.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.5 KB  |  77 lines

  1. // UrgencesButton.java
  2. // 19.03.96
  3. //
  4. // the button to take you to the urgences screen
  5.  
  6. package cybcerone.control;
  7.  
  8. import java.awt.Rectangle;
  9. import java.awt.Event;
  10.  
  11. import cybcerone.utils.Appletlike;
  12. import cybcerone.utils.IdPanel;
  13.  
  14.  
  15. /**
  16.  * The button to go to the urgency screen.
  17.  */
  18. class UrgencesButton extends ControlButton {
  19.   private static final Rectangle placement = 
  20.     new Rectangle (202, 0, 80, 100);
  21.   
  22.   private static final String id = "UrgencesButton";
  23.   private static final String statusText = "In case of emergency...";
  24.  
  25.   private static final String bgFile = imagePath + "sos_lache.gif";
  26.   private static final String pressedBgFile = imagePath + "sos_presse.gif";
  27.  
  28.   protected boolean screenUp;
  29.   BackButton back;
  30.  
  31.   UrgencesButton (BackButton back, Appletlike app) {
  32.     super (id, statusText, app);
  33.     reshape (placement);
  34.     this.back = back;
  35.  
  36.     setBackground (bgFile, 0);
  37.     setPressedBg (pressedBgFile, 0);
  38.  
  39.     screenUp = false;
  40.   }
  41.  
  42.   void update (String newPanelId) {
  43.     enable ();
  44.     if (newPanelId.equals (next)) {
  45.       screenUp = true;
  46.       pressed = true;
  47.       repaint ();
  48.     } else {
  49.       pressed = false;
  50.       screenUp = false;
  51.       repaint ();
  52.     }
  53.   }
  54.  
  55.   public boolean mouseUp (Event evt, int x, int y) {
  56.     if (pressed) {
  57.       if (screenUp) {
  58.     pressed = false;
  59.     repaint ();
  60.     back.doAction ();
  61.       } else {
  62.     doAction ();
  63.     screenUp = true;
  64.       }
  65.     }
  66.     return true;
  67.   }
  68.  
  69.   public boolean mouseExit (Event evt, int x, int y) {
  70.     if (!screenUp)
  71.       return super.mouseExit (evt, x, y);
  72.     else
  73.       return true;
  74.   }
  75.  
  76. }
  77.