home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Anachriz / programming / InputMaze.java.txt < prev    next >
Encoding:
Text File  |  2000-05-25  |  3.8 KB  |  138 lines

  1. abel.setText("");
  2.         try
  3.         {
  4.             M = Integer.parseInt(mTextField.getText());
  5.             N = Integer.parseInt(nTextField.getText());
  6.         }
  7.         catch(NumberFormatException ex)
  8.         {
  9.             output.setText("No numbers.");
  10.             return;
  11.         }
  12.         if(M <= 0 || M > 20 || N <= 0 || N > 30)
  13.         {
  14.             output.setText("Illegal values.");
  15.             return;
  16.         }
  17.         output.setText("");
  18.         panel.hide();
  19.         panel.removeAll();
  20.         panel.setLayout(new GridLayout(M, N));
  21.         panel.reshape(12, 140, N * 14, M * 14);
  22.         Checkbox c = new Checkbox();
  23.         c.disable();
  24.         panel.add(c);
  25.         for(int i = 1; i < M * N - 1; i++)
  26.             panel.add(new Checkbox());
  27.  
  28.         c = new Checkbox();
  29.         c.disable();
  30.         panel.add(c);
  31.         panel.validate();
  32.         panel.show();
  33.         array = new byte[M][N];
  34.         solveButton.show();
  35.         buttonLabel.setText("(4) Push this button to solve this maze");
  36.     }
  37.  
  38.     public void init()
  39.     {
  40.         super.init();
  41.         addNotify();
  42.                 
  43.         //{{INIT_CONTROLS
  44.         setLayout(null);
  45.         resize(482,515);
  46.         setBackground(new Color(12632256));
  47.         titleLabel = new java.awt.Label("Find shortest path in Maze");
  48.         titleLabel.reshape(12,0,339,25);
  49.         titleLabel.setFont(new Font("Dialog", Font.BOLD, 16));
  50.         add(titleLabel);
  51.         //}}
  52.         
  53.         mTextField = new TextField();
  54.         mTextField.reshape(12, 32, 99, 27);
  55.         add(mTextField);
  56.         nTextField = new TextField();
  57.         nTextField.reshape(12, 68, 99, 25);
  58.         add(nTextField);
  59.         inputMazeButton = new Button("Edit new maze");
  60.         inputMazeButton.reshape(12, 104, 98, 25);
  61.         add(inputMazeButton);
  62.         label1 = new Label("(1) Fill in the number of rows (1-20)");
  63.         label1.reshape(120, 32, 204, 24);
  64.         add(label1);
  65.         label2 = new Label("(2) Fill in the number of columns (1-30)");
  66.         label2.reshape(120, 68, 205, 26);
  67.         add(label2);
  68.         label3 = new Label("(3) Push this button to edit the maze");
  69.         label3.reshape(120, 104, 336, 26);
  70.         add(label3);
  71.         panel = new Panel();
  72.         panel.setLayout(null);
  73.         panel.reshape(12, 152, 120, 108);
  74.         add(panel);
  75.         solveButton = new Button("Solve!");
  76.         solveButton.hide();
  77.         solveButton.reshape(12, 440, 120, 26);
  78.         add(solveButton);
  79.         output = new TextField();
  80.         output.setEditable(false);
  81.         output.reshape(12, 476, 420, 22);
  82.         add(output);
  83.         editButton = new Button("Edit current maze");
  84.         editButton.hide();
  85.         editButton.reshape(12, 440, 120, 24);
  86.         add(editButton);
  87.         buttonLabel = new Label("");
  88.         buttonLabel.reshape(144, 440, 332, 22);
  89.         add(buttonLabel);
  90. }
  91.  
  92.     public boolean handleEvent(Event event)
  93.     {
  94.         if(event.target == inputMazeButton && event.id == 1001)
  95.         {
  96.             inputMazeButton_Clicked(event);
  97.             return true;
  98.         }
  99.         if(event.target == solveButton && event.id == 1001)
  100.         {
  101.             solveButton_Clicked(event);
  102.             return true;
  103.         }
  104.         if(event.target == editButton && event.id == 1001)
  105.         {
  106.             editButton_Clicked(event);
  107.             return true;
  108.         }
  109.         else
  110.         {
  111.             return super.handleEvent(event);
  112.         }
  113.     }
  114.  
  115.     public InputMaze()
  116.     {
  117.     }
  118.  
  119.     int M;
  120.     int N;
  121.     byte array[][];
  122.     Maze maze;
  123.     TextField mTextField;
  124.     TextField nTextField;
  125.     Button inputMazeButton;
  126.     Label label1;
  127.     Label label2;
  128.     Label label3;
  129.     Panel panel;
  130.     Button solveButton;
  131.     TextField output;
  132.     Button editButton;
  133.     Label buttonLabel;
  134.     //{{DECLARE_CONTROLS
  135.     java.awt.Label titleLabel;
  136.     //}}
  137. }
  138.