📄 cubeapp.java
字号:
/*
* Java Virtual Cube
* -----------------
*
* Copyright 1996, Song Li
* URL: http://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 Checkbox LightCheckbox ;
private Label StepLabel ;
private Label StepText ;
public void init () {
setSize(getSize().width <= 250 ? 250 : getSize().width,
getSize().height <= 300 ? 300 : getSize().height);
setLayout (null);
Panel control = new Panel ();
control.setLayout (null) ;
add (control) ;
control.setBounds (0, 200,getSize().width, getSize().height) ;
NewButton = new Button ("New") ;
ScrambleButton = new Button ("Scramble") ;
SolveButton = new Button ("Solve") ;
AboutButton = new Button ("About") ;
UndoButton = new Button ("Undo") ;
RedoButton = new Button ("Redo") ;
SoundCheckbox = new Checkbox ("Move") ;
LightCheckbox = new Checkbox ("Light") ;
StepLabel = new Label ("Step") ;
StepText = new Label ("0") ;
SoundCheckbox.setState (false) ;
LightCheckbox.setState (false) ;
control.add (NewButton) ;
control.add (ScrambleButton) ;
control.add (SolveButton) ;
control.add (AboutButton) ;
control.add (UndoButton) ;
control.add (RedoButton) ;
control.add (SoundCheckbox) ;
control.add (LightCheckbox) ;
control.add (StepLabel) ;
control.add (StepText) ;
CubeWin = new CubePanel (StepText) ;
CubeWin.setLayout (null) ;
add (CubeWin) ;
CubeWin.setBounds (0, 0, 250, 200) ;
CubeWin.DefineBound () ;
CubeWin.BadSound = getAudioClip (getCodeBase (), "illegal.au");
CubeWin.SpinSound = getAudioClip (getCodeBase (), "spin.au");
NewButton.setBounds (10, 5, 60, 25) ; AboutButton.setBounds (80, 5, 60, 25) ;
ScrambleButton.setBounds (10, 35, 60, 25) ; SolveButton.setBounds (80, 35, 60, 25) ;
UndoButton.setBounds (10, 65, 60, 25) ; RedoButton.setBounds (80, 65, 60, 25) ;
StepLabel.setBounds (150, 5, 25, 25) ;
StepText.setBounds (180, 5, 30, 25) ;
SoundCheckbox.setBounds (150, 35, 60, 25) ;
LightCheckbox.setBounds (150, 65, 60, 25) ;
}
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 if (event.target == LightCheckbox)
Face.SetLight (LightCheckbox.getState ());
else
CubeWin.CommandAction (event) ;
return true ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -