public void actionPerformed(ActionEvent e) {

        if (e.getSource() == update) {
            Graph g = graphPanel.getGraph();
            g.plotSettings.setMinX(Double.parseDouble(minX.getText()));
            g.plotSettings.setMaxX(Double.parseDouble(maxX.getText()));
            g.plotSettings.setMinY(Double.parseDouble(minY.getText()));
            g.plotSettings.setMaxY(Double.parseDouble(maxY.getText()));
            graphPanel.repaint();
        }

        // Saves an image of the graph to disk.
        if (e.getSource() == save) {
            JFileChooser filechooser = new JFileChooser(System.getProperty("user.home"));
            filechooser.setDialogTitle("Save Graph Image");
            filechooser.setSelectedFile(new File(filechooser.getCurrentDirectory(), "graph.png"));
            filechooser.setFileFilter(new FileFilter() {
                public boolean accept(File f) {
                    String extension = f.getName().substring(f.getName().lastIndexOf('.') + 1).toLowerCase();
                    if (f.isDirectory()) return true;
                    if (extension.equals("bmp")) return true;
                    if (extension.equals("jpg")) return true;
                    if (extension.equals("png")) return true;
                    return false;
                }

                public String getDescription() {
                    return "Image Files: jpg, png, bmp";
                }
            });
            int action = filechooser.showSaveDialog(this);
            if (action == JFileChooser.APPROVE_OPTION) {
                File f = filechooser.getSelectedFile();
                try {
                    String extension = f.getName().substring(f.getName().lastIndexOf(".") + 1);
                    javax.imageio.ImageIO.write(graphPanel.getImage(), extension, f);
                } catch (IOException err) {
                    JOptionPane.showMessageDialog(this, "Could not save image: " + err.getMessage());
                }
            }
        }

        // Exits the program.
        if (e.getSource() == exit) {
            System.exit(0);
        }

    }