home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-09-28 | 2.0 KB | 76 lines | [TEXT/CWIE] |
- public class PlayPauseButton extends RolloverButton
- {
- //Declare and define constants
- //Insert "PlayPauseButton Constants"
- public static final String PLAY_UP_IMAGE = "play up";
- public static final String PLAY_DOWN_IMAGE = "play down";
- public static final String PLAY_ROLLOVER_IMAGE = "play rollover";
- public static final String PAUSE_UP_IMAGE = "pause up";
- public static final String PAUSE_DOWN_IMAGE = "pause down";
- public static final String PAUSE_ROLLOVER_IMAGE = "pause rollover";
-
- public static final int PLAY_STATE = 0;
- public static final int PAUSE_STATE = 1;
-
- public void initImages()
- {
- //Initialize images and set the state for the PlayPauseButton
- //Insert "PlayPauseButton initImages"
- addImage("images/play.jpg", PLAY_UP_IMAGE);
- addImage("images/playa.jpg", PLAY_DOWN_IMAGE);
- addImage("images/playb.jpg", PLAY_ROLLOVER_IMAGE);
- addImage("images/pause.jpg", PAUSE_UP_IMAGE);
- addImage("images/pausea.jpg", PAUSE_DOWN_IMAGE);
- addImage("images/pauseb.jpg", PAUSE_ROLLOVER_IMAGE);
-
- setState(PLAY_STATE);
- }
-
- /**
- * Sets the state of the PlayPauseButton.
- * @param the state to use.
- * @see #PLAY_STATE
- * @see #PAUSE_STATE
- */
- public void setState(int state)
- {
- //Handle switching states
- //Insert "PlayPauseButton setState"
- switch (state)
- {
- case PLAY_STATE:
- upImage = PLAY_UP_IMAGE;
- downImage = PLAY_DOWN_IMAGE;
- rolloverImage = PLAY_ROLLOVER_IMAGE;
- setActionCommand("" + PLAY_STATE);
- this.state = state;
- refreshImage();
- break;
- case PAUSE_STATE:
- upImage = PAUSE_UP_IMAGE;
- downImage = PAUSE_DOWN_IMAGE;
- rolloverImage = PAUSE_ROLLOVER_IMAGE;
- setActionCommand("" + PAUSE_STATE);
- this.state = state;
- refreshImage();
- break;
- }
- }
-
- /**
- * Gets the state of the PlayPauseButton.
- * @return the state currently in use.
- * @see #PLAY_STATE
- * @see #PAUSE_STATE
- */
- public int getState()
- {
- //Return the current state
- //Insert "PlayPauseButton getState"
- return state;
- }
-
- //Declare data members
- //Insert "PlayPauseButton data members"
- protected int state;
- }