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

  1. // ForwardButton.java
  2. // 19.03.96
  3. //
  4. // the forward button on the control panel
  5.  
  6. package cybcerone.control;
  7.  
  8. import java.awt.Rectangle;
  9. import java.util.Stack;
  10.  
  11. import cybcerone.utils.Appletlike;
  12. import cybcerone.utils.IdPanel;
  13.  
  14. /**
  15.  * The button to advance forward in the history list.
  16.  */
  17. class ForwardButton extends ControlButton {
  18.   private static final Rectangle placement = 
  19.     new Rectangle (589, 0, 80, 100);
  20.   
  21.   private static final String id = "ForwardButton";
  22.   private static final String statusText = "Click to go Forward";
  23.  
  24.   private static final String bgFile = imagePath + "avance_lache.gif";
  25.   private static final String pressedBgFile = imagePath + "avance_presse.gif";
  26.   private static final String disabledBgFile = 
  27.     imagePath + "avance_disabled.gif";
  28.   
  29.   ControlPanel parent;
  30.   Stack future;
  31.  
  32.   ForwardButton (ControlPanel parent, Appletlike app) {
  33.     super (id, statusText, app);
  34.     reshape (placement);
  35.     this.parent = parent;
  36.  
  37.     setBackground (bgFile, 1);
  38.     setPressedBg (pressedBgFile, 1);
  39.     setDisabledBg (disabledBgFile, 0);
  40.  
  41.     clear ();
  42.   }
  43.  
  44.   void clear () {
  45.     future = new Stack ();
  46.     disable ();
  47.   }
  48.  
  49.   void update (Object newPanelId) {
  50.     future.push (newPanelId);
  51.     enable ();
  52.   }
  53.  
  54.   protected void doAction () {
  55.     parent.goForward (future.pop ());
  56.     if (future.empty ())
  57.       disable ();
  58.   }
  59. }
  60.