rubiksimul.java

来自「魔方问题是算法设计中一个难点」· Java 代码 · 共 57 行

JAVA
57
字号



import java.awt.*;
import java.applet.Applet;
public class RubikSimul extends Applet {
  RubikCube R;

  public Color getBackground() {
    return Color.lightGray;
  }

  public void init() {
    add (new Button ("Grundstellung"));
    R = new RubikCube();
  }

  public Dimension preferredSize () {
    // definiert in Basisklasse Component, wird vom Layout-Manager verwendet
    return Prj.preferredSize ();
  }

  public boolean mouseDown (Event evt, int x, int y) {
    R.onMouseClick (x, y);
    R.paint (getGraphics());
    return true;
  }

  public boolean mouseMove (Event evt, int x, int y) {
    Graphics g = getGraphics();
    R.onMouseMove (g, x, y);
    return true;
  }

  public boolean action (Event evt, Object arg) {
    if ("Grundstellung".equals(arg)) {
      R.reset();
      R.paint (getGraphics());
      return true;
    }
    return false;
  }

  public void paint (Graphics g) {
    R.paint (g);
  }

  public String getAppletInfo() {
    return "Rubik-Simulator (H.R.)";
  }

  /*** nur fuer die Application-Version:
  public static void main (String args[]) {
    AppletFrame.startApplet ("RubikSimul", "Rubik-Simulator");
  }
  ***/
}

⌨️ 快捷键说明

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