public MainFrame() {
        //初始化
        super("分治法");
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setSize(width, height);
        this.setResizable(false);
        this.setVisible(true);

        //顶部放置菜单
        this.add(topPanel, BorderLayout.NORTH);
        topPanel.setSize(WIDTH, panelHeight);
        topPanel.add(new JLabel("X : "));
        topPanel.add(xField);
        topPanel.add(new JLabel("Y : "));
        topPanel.add(yField);
        topPanel.add(addBtn);
        //添加
        addBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg) {
                String sx = xField.getText();
                String sy = yField.getText();
                xField.setText("");
                yField.setText("");
                int x, y;
                //坐标转换
                try {
                    x = Integer.parseInt(sx) + width/2;
                    y = height/2 - panelHeight - Integer.parseInt(sy);
                } catch (NumberFormatException e) {
                    return;
                }
                if (ifOut(x, y)) {
                    return;
                }
                addPoint(x, y);
            }
        });

        topPanel.add(new JSeparator());
        topPanel.add(resetBtn);
        //重置
        resetBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg) {
                System.out.println("resetBtn");
                resetPoints();
            }
        });
        topPanel.add(new JSeparator());
        topPanel.add(label);
        topPanel.add(resultBtn);
        //计算
        resultBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg) {
                if (points.size() < 2) {
                    return;
                }
                //清空上次结果
                if (hasResult) {
                    resetPoints();
                    return;
                }
                //计算
                hasResult = true;
                Calculation c = new Calculation(points);
                c.work();
                pointCanvas.drawResult(true, c.getMinDis(), c.getPairPoints());
                pointCanvas.repaint();
                System.out.println("resultBtn");
            }
        });

        //中间放置画布
        this.add(pointCanvas, BorderLayout.CENTER);
        pointCanvas.setBackground(Color.white);
        pointCanvas.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (ifOut(e.getX(), e.getY())) {
                    return;
                }
                addPoint(e.getX(), e.getY());
            }
        });

    }