home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.5 KB | 70 lines |
- // BackButton.java
- // 19.03.96
- //
- // the Back button on the control panel
-
- package cybcerone.control;
-
- import java.awt.Rectangle;
- import java.util.Stack;
-
- import cybcerone.utils.Appletlike;
- import cybcerone.utils.IdPanel;
-
- /**
- * Allows the user to go back to previous pages.
- */
- class BackButton extends ControlButton {
- private static final Rectangle placement =
- new Rectangle (354, 0, 80, 100);
-
- private static final String id = "BackButton";
- private static final String statusText = "Click to go Back";
-
- private static final String bgFile = imagePath + "retour_lache.gif";
- private static final String pressedBgFile = imagePath + "retour_presse.gif";
- private static final String disabledBgFile =
- imagePath + "retour_disabled.gif";
-
- ControlPanel parent;
- Stack history;
-
- BackButton (ControlPanel parent, Appletlike app) {
- super (id, statusText, app);
- reshape (placement);
- this.parent = parent;
-
- setBackground (bgFile, 1);
- setPressedBg (pressedBgFile, 1);
- setDisabledBg (disabledBgFile, 0);
-
- clear ();
- }
-
- /**
- * We're leaving this page, store it so we can get back.
- */
- void update (Object newPanelId) {
- history.push (newPanelId);
- enable ();
- }
-
- /**
- * Takes us back a page.
- */
- protected void doAction () {
- parent.goBack (history.pop ());
- if (history.empty ())
- disable ();
- }
-
- /**
- * Back to the initial state.
- */
- public void clear () {
- history = new Stack ();
- disable ();
- }
-
- }
-