⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cubeapp.java

📁 一个java写的魔方游戏
💻 JAVA
字号:
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 ;
    }


}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -