// enters puzzles into the listmodel
 void enterPuzzle(String catagoryName) {
   CategoryNode tmp = ChessApplication.l.head;
   while (tmp != null) {
     if (catagoryName.equalsIgnoreCase(tmp.categoryName)) {
       Puzzle temp = tmp.h;
       while (temp != null) {
         listmodel.addElement(temp.getFenString());
         temp = temp.next;
       }
       break;
     }
     tmp = tmp.next;
   }
 }
  // again, sets the gui
  void init(final int perspective, final Puzzle puzzle) {
    con.removeAll();
    setBounds(0, 0, 1400, 1030);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel header = new JLabel("Edit Puzzle");
    header.setFont(new Font("Serif", Font.BOLD, 40));
    header.setForeground(Color.BLACK);
    header.setBounds(600, 0, 290, 50);
    canvas = new MyCanvas(perspective);
    canvas.setBounds(30, 120, 800, 800);
    canvas.boxItem = puzzle.boxItems;
    canvas.isfromEditBoard = true;
    panel.setBackground(Color.orange);
    panel.setBounds(0, 0, 1300, 1000);
    JLabel[] alphabets = asigningalphabets(perspective);
    JLabel[] alphabets1 = asigningalphabets1(perspective);
    JLabel[] numbers = assigningnumbers(perspective);
    JLabel[] numbers1 = assigningnumbers1(perspective);
    JButton buttonNext = new JButton("Edit");
    buttonNext.setBounds(1150, 850, 120, 30);
    buttonNext.setFont(new Font("Serif", Font.BOLD, 20));
    buttonNext.setFocusable(false);
    JButton backButton = new JButton("Return");
    backButton.setBounds(930, 850, 120, 30);
    backButton.setFont(new Font("Serif", Font.BOLD, 20));
    backButton.setFocusable(false);
    listmodel = new DefaultListModel();
    enterPuzzle(puzzle.getcategoryName());
    final JList listofMoves = new JList(listmodel);
    JScrollPane list = new JScrollPane();
    list.setViewportView(listofMoves);
    list.setBounds(870, 350, 500, 300);
    listofMoves.setFont(new Font("Serif", Font.PLAIN, 20));
    for (int i = 0; i < listmodel.getSize(); i++) {
      CategoryNode tmp = ChessApplication.l.head;
      while (tmp != null) {
        if (tmp.categoryName.equalsIgnoreCase(puzzle.getcategoryName())) {
          Puzzle temp = tmp.h;
          int counter = 0;
          while (temp != null) {
            if (temp.getFenString().equalsIgnoreCase(puzzle.getFenString())) {
              listofMoves.setSelectedIndex(counter);
            }
            temp = temp.next;
            counter++;
          }
        }
        tmp = tmp.next;
      }
    }
    JLabel categoryLabel = new JLabel("Select Category");
    categoryLabel.setFont(new Font("Serif", Font.BOLD, 20));
    categoryLabel.setBounds(1020, 160, 290, 30);
    JLabel movesLabel = new JLabel("Select Puzzle");
    movesLabel.setFont(new Font("Serif", Font.BOLD, 20));
    movesLabel.setBounds(1030, 310, 290, 30);
    DefaultComboBoxModel catagorylist = new DefaultComboBoxModel();
    for (int i = 1; i < BoardtoAdd.listofCategory.getSize(); i++) {
      catagorylist.addElement(BoardtoAdd.listofCategory.getElementAt(i));
    }
    final JComboBox categoryBox = new JComboBox(catagorylist);
    categoryBox.setBounds(1000, 200, 200, 30);
    categoryBox.setFont(new Font("Serif", Font.BOLD, 20));
    categoryBox.setSelectedItem(puzzle.getcategoryName());
    backButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            setRunningFalse();
            ChessApplication.editboard.setVisible(false);
            ChessApplication.startform.setVisible(true);
          }
        });
    buttonNext.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            setRunningFalse();
            ChessApplication.editboard.setVisible(false);
            ChessApplication.boardtoedit.init("Edit Moves", perspective, false, puzzle);
          }
        });
    listofMoves.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseClicked(MouseEvent e) {
            setRunningFalse();
            ChessApplication.editboard.setVisible(false);
            puzzle.setBoxItems();
            ChessApplication.editboard.init(
                getPuzzle(categoryBox.getSelectedItem().toString(), listofMoves.getSelectedIndex())
                    .position
                    .getToPlay(),
                getPuzzle(
                    categoryBox.getSelectedItem().toString(), listofMoves.getSelectedIndex()));
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}
        });
    categoryBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            setRunningFalse();
            ChessApplication.editboard.setVisible(false);
            puzzle.setBoxItems();
            ChessApplication.editboard.init(
                getPuzzle(categoryBox.getSelectedItem().toString()).position.getToPlay(),
                getPuzzle(categoryBox.getSelectedItem().toString()));
          }
        });
    for (int i = 0; i < 8; i++) {
      con.add(alphabets[i]);
      con.add(numbers[i]);
      con.add(alphabets1[i]);
      con.add(numbers1[i]);
    }
    con.add(categoryLabel);
    con.add(movesLabel);
    con.add(categoryBox);
    con.add(list);
    con.add(backButton);
    con.add(buttonNext);
    con.add(header);
    con.add(canvas);
    con.setBackground(Color.orange);
    con.add(panel);
    setVisible(true);
    canvas.start();
  }