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

📄 mazeview.java

📁 一个迷宫的JAVA程序
💻 JAVA
字号:
import javax.swing.*;
import BreezySwing.*;

public class MazeView extends GBFrame {

   MazeModel model;
//   MazeView mv;

   JTextArea textArea
                        = addTextArea ("Maze Solution",1,1,31,31);
   JButton resetButton
                        = addButton ("Reset",32,1,1,1);
   JButton startButton
                        = addButton ("Start",32,2,1,1);
   JButton resultButton
                        = addButton ("Result",32,3,1,1);

   public void buttonClicked (JButton buttonObj){
      if (buttonObj == resetButton) resetMaze();
      else
        if (buttonObj == startButton) {
            String str = textArea.getText(); // collect the maze string in view
            model.setMaze(str);  // set the 2-D Array in model
            textArea.setText(model.getMaze()); // ReDisplay the maze string
            messageBox("Now we will enter solveMaze...");
            boolean success = model.solveMaze();
            messageBox("Exited from solveMaze(), and will ReDisplay the result");
            if (success) textArea.setText(model.getMaze());
            else             
              messageBox("This maze has no solution, Reset and try another one");
        } 
        else textArea.setText(model.getResult());     
   }         

   public void resetMaze(){
     model.initMaze();
     printMaze();
   }
   public void printMaze() {     
     String str = model.getMaze();
     textArea.setText(str);
   }    
   public MazeView() { // constructor
   model = new MazeModel(this);
   this.printMaze();
   }

   public static void main (String[] args){
      MazeView mv = new MazeView();
      mv.setTitle("Maze Solution");
      mv.setSize (250, 250);
      mv.setVisible (true);
   }
}

⌨️ 快捷键说明

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