home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-05-13 | 3.4 KB | 108 lines |
-
-
- /*
-
- * Java Rubik's Cube
-
- * -----------------
-
- *
-
- * Copyright 1996, Song Li
-
- * URL: www.cs.umbc.edu/~sli2
-
- *
-
- *
-
- * You can use the code for any nonprofittable use. But remember to mention
-
- * the authors' names in your revised program. You are also encouraged to
-
- * improve the program or give your comments and bug reports. If there are
-
- * further questions, please contact me and I'll be glad to help. My E-Mail
-
- * address is: sli2@gl.umbc.edu.
-
- *
-
- */
-
-
-
-
-
- import java.applet.Applet;
-
- import java.awt.*;
-
-
-
-
-
-
-
- public class CubeApp extends Applet {
-
-
-
- private CubePanel CubeWin ;
-
-
-
- private Button NewButton ;
-
- private Button ScrambleButton ;
-
- private Button SolveButton ;
-
- private Button AboutButton ;
-
- private Button UndoButton ;
-
- private Button RedoButton ;
-
- private Checkbox SoundCheckbox ;
-
- private Label StepLabel ;
-
- private TextField StepText ;
-
-
-
-
-
-
-
- public void init () {
-
- resize(size().width <= 420 ? 420 : size().width,
-
- size().height <= 200 ? 200 : size().height);
-
-
-
-
-
- setLayout (null);
-
- Panel control = new Panel ();
-
- control.setLayout (null) ;
-
- add (control) ;
-
- control.reshape (0, 0, 200, size().height) ;
-
-
-
- NewButton = new Button ("New Game") ;
-
- ScrambleButton = new Button ("Scramble") ;
-
- SolveButton = new Button ("Solve") ;
-
- AboutButton = new Button ("About") ;
-
- UndoButton = new Button ("Undo") ;
-
- RedoButton = new Button ("Redo") ;
-
- SoundCheckbox = new Checkbox ("Sound") ;
-
- StepLabel = new Label ("Step") ;
-
- StepText = new TextField ("0") ;
-
- StepText.setEditable (false) ;
-
- SoundCheckbox.setState (true) ;
-
-
-
- add (NewButton) ;
-
- add (ScrambleButton) ;
-
- add (SolveButton) ;
-
- add (AboutButton) ;
-
- add (UndoButton) ;
-
- add (RedoButton) ;
-
- add (SoundCheckbox) ;
-
- add (StepLabel) ;
-
- add (StepText) ;
-
-
-
- NewButton.reshape (10, 10, 80, 25) ; AboutButton.reshape (110, 10, 80, 25) ;
-
- ScrambleButton.reshape (10, 40, 80, 25) ; SolveButton.reshape (110, 40, 80, 25) ;
-
- UndoButton.reshape (10, 70, 80, 25) ; RedoButton.reshape (110, 70, 80, 25) ;
-
- StepLabel.reshape (10, 160, 40, 25) ; SoundCheckbox.reshape (110, 160, 80, 25) ;
-
- StepText.reshape (40, 158, 40, 29) ;
-
-
-
- CubeWin = new CubePanel (StepText) ;
-
- CubeWin.setLayout (null) ;
-
- add (CubeWin) ;
-
- CubeWin.reshape (220, 0, size().width-220, size().height) ;
-
- CubeWin.DefineBound () ;
-
-
-
- CubeWin.BadSound = getAudioClip (getCodeBase (), "illegal.au");
-
- CubeWin.SpinSound = getAudioClip (getCodeBase (), "spin.au");
-
- }
-
-
-
-
-
- public void start () {CubeWin.Start () ;}
-
- public void stop () {CubeWin.Stop () ;}
-
-
-
-
-
- public synchronized boolean handleEvent (Event event) {
-
- if (event.id == Event.ACTION_EVENT)
-
- if (event.target == AboutButton) {
-
- CubeAbout about = new CubeAbout () ;
-
- about.show () ;
-
- } else
-
- CubeWin.CommandAction (event) ;
-
- return true ;
-
- }
-
-
-
-
-
- }
-
-
-
-
-
-