private void setupEventListener() {
        // menuitem event listener
        undoMenuItem.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK));
        redoMenuItem.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK));
        cutMenuItem.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
        copyMenuItem.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
        pasteMenuItem.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK));
        pasteToNewMenuItem.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK));
        cropMenuItem.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.CTRL_MASK));

        undoMenuItem.addActionListener(e -> {
            mainFrame.undoSelectedFrame();
            updateEditMenuItemBtn();
        });

        redoMenuItem.addActionListener(e -> {
            mainFrame.redoSelectedFrame();
            updateEditMenuItemBtn();
        });

        cutMenuItem.addActionListener(e -> {
            copyToClipboard();
            mainFrame.cleanSelectedAreaOfSelectedFrame();
            pasteToNewMenuItem.setEnabled(true);
            updateEditMenuItemBtn();
        });

        copyMenuItem.addActionListener(e -> {
            copyToClipboard();
            pasteToNewMenuItem.setEnabled(true);
            updateEditMenuItemBtn();
        });

        pasteMenuItem.addActionListener(e -> {
            mainFrame.pasteToSelectedFrame();
        });

        pasteToNewMenuItem.addActionListener(e -> {
            pasteToNew();
        });

        cropMenuItem.addActionListener(e -> {
            mainFrame.cropSelectedFrame();
            updateEditMenuItemBtn();
        });

        resizeMenuItem.addActionListener(e -> {
            resize();
            updateEditMenuItemBtn();
        });

        horizontalMirrorMenuItem.addActionListener(e -> {
            mainFrame.mirrorSelectedFrame(ImageProcessor::horizontalMirror);
            updateEditMenuItemBtn();
        });

        verticalMirrorMenuItem.addActionListener(e -> {
            mainFrame.mirrorSelectedFrame(ImageProcessor::verticalMirror);
            updateEditMenuItemBtn();
        });

        clockwiseMenuItem.addActionListener(e -> {
            mainFrame.rotateSelectedFrame(ImageProcessor::clockwise);
            updateEditMenuItemBtn();
        });

        counterClockwiseMenuItem.addActionListener(e -> {
            mainFrame.rotateSelectedFrame(ImageProcessor::counterClockwise);
            updateEditMenuItemBtn();
        });

        batchMenuItem.addActionListener(e -> {
            batch();
            updateEditMenuItemBtn();
        });

        // tool bar
        foreColorBox.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                Color color = JColorChooser.showDialog(null, "Color information", foreColorBox.getColor());
                if (color != null) {
                    foreColorBox.setColor(color);
                    foreColorBox.repaint();
                    if(!mainFrame.noSelectedFrame()) {
                        mainFrame.setImageForegroundOfSelected(color);
                    }
                }
            }
        });

        backColorBox.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                Color color = JColorChooser.showDialog(null, "Color information", backColorBox.getColor());
                if (color != null) {
                    backColorBox.setColor(color);
                    backColorBox.repaint();
                    if(!mainFrame.noSelectedFrame()) {
                        mainFrame.setImageBackgroundOfSelected(color);
                    }
                }
            }
        });

        selectBtn.addActionListener(e -> {
            editMode = MainFrame.SelectionMode;
        });

        brushBtn.addActionListener(e -> {
            editMode = MainFrame.BrushMode;
        });

        textBtn.addActionListener(e -> {
            editMode = MainFrame.TextMode;
        });

        viewBtn.addActionListener(e -> {
            editMode = MainFrame.ViewMode;
        });

        brushSpinner.addChangeListener(e -> {
            if (((Integer) brushSpinner.getValue()) <= 0) {
                brushSpinner.setValue(1);
            }
        });

        cutBtn.addActionListener(e -> {
            copyToClipboard();
            mainFrame.cleanSelectedAreaOfSelectedFrame();
            pasteToNewMenuItem.setEnabled(true);
            updateEditMenuItemBtn();
        });

        copyBtn.addActionListener(e -> {
            copyToClipboard();
            pasteToNewMenuItem.setEnabled(true);
            updateEditMenuItemBtn();
        });

        pasteBtn.addActionListener(e -> {
            editMode = MainFrame.PasteMode;
            mainFrame.pasteToSelectedFrame();
        });

        cropBtn.addActionListener(e -> {
            mainFrame.cropSelectedFrame();
            updateEditMenuItemBtn();
        });

    }