@Action
    public void open() {
        if (!saved) {
            int option = JOptionPane.showConfirmDialog(this.getFrame(), "Do you want to save changes to your current file?", "Open", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
            switch (option) {
                case JOptionPane.YES_OPTION:
                    save();
                    break;
                case JOptionPane.CANCEL_OPTION:
                    return;
            }
        }
        if (fileChooser.showOpenDialog(this.getFrame()) == JFileChooser.APPROVE_OPTION) {
            File file = fileChooser.getSelectedFile();
            BufferedReader reader = null;
            try {
                reader = new BufferedReader(new FileReader(file));
                StringBuffer text = new StringBuffer();
                while (reader.ready()) {
                    text.append((char) reader.read());
                }
                editor.setText(text.toString());
                updateLineNum();
                currentFile = file;
                saved = true;
                updateTab();
                updateUndoRedo();
            } catch (FileNotFoundException ex) {
                JOptionPane.showMessageDialog(this.getFrame(), "File " + file.getName() + " doesn't exist.", "Error", JOptionPane.ERROR_MESSAGE);
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(this.getFrame(), "An error occured while opening.", "Error", JOptionPane.ERROR_MESSAGE);
            } finally {
                try {
                    reader.close();
                } catch (IOException ex) {
                }
            }
        }
    }