Package maze.gui

Examples of maze.gui.PrimaryFrame


      SwingUtilities.invokeLater(new Runnable()
      {
         @Override
         public void run()
         {
            primaryFrame = new PrimaryFrame();
            primaryFrame.init();
            primaryFrame.setVisible(true);
         }
      });
   }
View Full Code Here


    * Save a maze.
    * @return The saved maze or null. Can return itself or a new instance.
    */
   public MazeInfo saveMaze()
   {
      final PrimaryFrame frame = Main.getPrimaryFrameInstance();
      DefaultComboBoxModel cbm = frame.getMazeInfoModel().getMazeInfoComboBoxModel();
      TreeSet<String> paths = new TreeSet<String>();
      for (int i = 0; i < cbm.getSize(); i++)
      {
         String path = ((MazeInfo) cbm.getElementAt(i)).getPath();
         if (path.isEmpty() == false)
            paths.add(path.toLowerCase());
      }
      if (this.isDirty())
      {
         MazeInfo toSave = this;
         if (!this.isMutable())
         {
            toSave = this.getMutableClone();
            Box box = new Box(BoxLayout.Y_AXIS);
            JLabel label = new JLabel("What would you like to call the" + " maze?");
            JTextField field = new JTextField();
            box.add(label);
            box.add(field);
            String newName = null;
            while (true)
            {
               int result = JOptionPane.showConfirmDialog(frame,
                                                          box,
                                                          "Maze Name",
                                                          JOptionPane.OK_CANCEL_OPTION,
                                                          JOptionPane.QUESTION_MESSAGE);
               if (result == JOptionPane.OK_OPTION)
               {
                  if (field.getText().length() > 0)
                  {
                     newName = field.getText();
                     break;
                  }
               }
               else
                  break;
            }
            if (newName == null)
               return null;
            this.clearDirty();
            toSave.setName(newName);
            toSave.setPath("");
            frame.getMazeInfoModel().addMaze(toSave);
            toSave.saveMaze();
            return toSave;
         }
         else if (this.getPath() == null || this.getPath().isEmpty())
         {
View Full Code Here

    * Prompt the user to save any dirty mazes.
    */
   @Override
   public boolean canExit()
   {
      final PrimaryFrame primary = Main.getPrimaryFrameInstance();
      DefaultComboBoxModel cbm = primary.getMazeInfoModel().getMazeInfoComboBoxModel();
      for (int i = 0; i < cbm.getSize(); i++)
      {
         MazeInfo mi = (MazeInfo) cbm.getElementAt(i);
         if (mi.isDirty())
         {
View Full Code Here

TOP

Related Classes of maze.gui.PrimaryFrame

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.