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

📄 maze.java

📁 这是一个可自动生成迷宫、自动或人工寻找迷宫路径的java程序
💻 JAVA
字号:
package maze;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Maze extends JFrame {    private JPanel cPane = (JPanel) getContentPane();    private MazeDraw mazeCavans = new MazeDraw();    private JSplitPane splitPane;    private ControlPanel controlPane;    private ConDialog mydialog = new ConDialog();    private int mancontrol = 0;    private Gen_Solve g;    private int pos;    private static int nextpos;    public Maze() {        init();    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }    }    public void init() {        setDefaultCloseOperation(EXIT_ON_CLOSE);        controlPane = new ControlPanel();        g = new Gen_Solve(controlPane, mazeCavans);        controlPane.addGenerateActionListener(new ActionListener() {                public void actionPerformed(ActionEvent event) {                    mancontrol = 1;                    Gen_Solve.isauto = 0;                    //g = new Gen_Solve(controlPane, mazeCavans);                    g.generate();                    nextpos = g.getStart();                    Gen_Solve.nowstart = g.getStart();                }            });        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,                                   controlPane, mazeCavans);        splitPane.setDividerLocation(120);        splitPane.setDividerSize(5);        cPane.add(splitPane, BorderLayout.CENTER);        setSize(640, 480);    }    public static void main(String[] args) {        Maze maze = new Maze();        maze.show();    }  private void jbInit() throws Exception {    this.setTitle("迷宫");    this.addKeyListener(new java.awt.event.KeyAdapter() {      public void keyPressed(KeyEvent e) {        this_keyPressed(e);      }    });  }  void this_keyPressed(KeyEvent e) {    if((mancontrol == 1)&&(Gen_Solve.isauto == 0)){      pos = g.man_solve(e,nextpos);      if(pos != -1)        nextpos = pos;    }  }}

⌨️ 快捷键说明

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