Example usage for java.beans PropertyChangeEvent getPropertyName

List of usage examples for java.beans PropertyChangeEvent getPropertyName

Introduction

In this page you can find the example usage for java.beans PropertyChangeEvent getPropertyName.

Prototype

public String getPropertyName() 

Source Link

Document

Gets the programmatic name of the property that was changed.

Usage

From source file:edu.ucla.stat.SOCR.analyses.gui.AnovaOneWay.java

/** Implementation of PropertyChageListener.*/
public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();

    System.err.println("From RegCorrAnal:: propertyName =" + propertyName + "!!!");

    if (propertyName.equals("DataUpdate")) {
        //update the local version of the dataTable by outside source
        dataTable = (JTable) (e.getNewValue());
        dataPanel.removeAll();//from  w  w w  .  ja  va  2s  .  c  om
        dataPanel.add(new JScrollPane(dataTable));

        System.err.println("From RegCorrAnal:: data UPDATED!!!");
    }
}

From source file:BeanContainer.java

public void propertyChange(PropertyChangeEvent evt) {
        m_data.setProperty(evt.getPropertyName(), evt.getNewValue());
    }

From source file:com.haulmont.cuba.web.toolkit.ui.CubaSideMenu.java

@SuppressWarnings("unchecked")
protected void menuItemPropertyChanged(PropertyChangeEvent event) {
    if (event.getPropertyName() == null) {
        return;/*from   ww  w. ja  v a  2s. c  o  m*/
    }

    if (!structureChanged && MENU_ITEM_BADGE_TEXT.equals(event.getPropertyName())) {
        badgeUpdates.add((MenuItem) event.getSource());
        markAsDirty();
    }

    if (MENU_ITEM_CHILDREN.equals(event.getPropertyName())) {
        List<MenuItem> oldItems = (List<MenuItem>) event.getOldValue();
        List<MenuItem> newItems = (List<MenuItem>) event.getNewValue();

        if (oldItems != null) {
            for (MenuItem oldItem : oldItems) {
                oldItem.removePropertyChangeListener(itemsPropertyChangeListener);
            }
        }
        if (newItems != null) {
            for (MenuItem newItem : newItems) {
                newItem.addPropertyChangeListener(itemsPropertyChangeListener);
            }
        }
    }

    switch (event.getPropertyName()) {
    case MENU_ITEM_CAPTION:
    case MENU_ITEM_DESCRIPTION:
    case MENU_ITEM_ICON:
    case MENU_ITEM_CHILDREN:
    case MENU_ITEM_STYLE_NAME:
    case MENU_ITEM_VISIBLE:
    case MENU_ITEM_ENABLED:
    case MENU_ITEM_CAPTION_AS_HTML:
    case MENU_ITEM_CUBA_ID:
    case MENU_ITEM_EXPANDED:
        markMenuStructureAsDirty();
        break;
    }
}

From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java

public void propertyChange(PropertyChangeEvent ev) {
    //System.err.println(ev);
    if (ev.getPropertyName().equals(ConceptsTreeDialog.PROPERTY_SELECTED_CONCEPTS)) {
        processSelectedConceptsChange(ev);
    } else if (ev.getPropertyName().equals(RegistryBrowser.PROPERTY_LOCALE)) {
        processLocaleChange((Locale) ev.getNewValue());
    }/*from   w  w  w  .  ja  v a 2s . co  m*/
}

From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java

private void openReportEditor(final String name) throws IOException {
    String formatStr = (String) JOptionPane.showInputDialog(null, "Select File Format", "File format",
            JOptionPane.QUESTION_MESSAGE, null, PluginConstants.REPORT_TEMPLATE_FORMATS,
            ReportTemplateFormat.FO.name());
    if (StringUtils.isNotBlank(formatStr)) {
        ReportTemplateFormat format = ReportTemplateFormat.valueOf(formatStr);

        InputStream is = null;/*from   w  ww .j  av  a2  s  .c  o  m*/
        try {
            switch (format) {
            case HTML:
                is = (InputStream) reportTemplateManagerService.getFormat(name, ReportTemplateFormat.HTML);
                break;
            case CSV:
                is = (InputStream) reportTemplateManagerService.getFormat(name, ReportTemplateFormat.CSV);
                break;
            case FO:
                is = (InputStream) reportTemplateManagerService.getFormat(name, ReportTemplateFormat.FO);
                break;
            default:
                LOG.log(Level.SEVERE, String.format("Format [%s] not supported", format));
                break;
            }
        } catch (SyncopeClientException e) {
            LOG.log(Level.SEVERE,
                    String.format("Unable to get [%s] report template in [%s] format", name, format), e);
            if (ClientExceptionType.NotFound.equals(e.getType())) {
                LOG.log(Level.SEVERE,
                        String.format("Report template [%s] not found, create an empty one", name));
            } else {
                JOptionPane.showMessageDialog(null,
                        String.format("Unable to get [%s] report template in [%s] format", name, format),
                        "Connection Error", JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception e) {
            LOG.log(Level.SEVERE,
                    String.format("Unable to get [%s] report template in [%s] format", name, format), e);
            JOptionPane.showMessageDialog(null,
                    String.format("Unable to get [%s] report template in [%s] format", name, format),
                    "Generic Error", JOptionPane.ERROR_MESSAGE);
        }
        String content = is == null ? StringUtils.EMPTY : IOUtils.toString(is, encodingPattern);

        String reportTemplatesDirName = System.getProperty("java.io.tmpdir") + "/Templates/Report/";
        File reportTemplatesDir = new File(reportTemplatesDirName);
        if (!reportTemplatesDir.exists()) {
            reportTemplatesDir.mkdirs();
        }
        File file = new File(reportTemplatesDirName + name + "." + format.name().toLowerCase());
        FileWriter fw = new FileWriter(file);
        fw.write(content);
        fw.flush();
        FileObject fob = FileUtil.toFileObject(file.getAbsoluteFile());
        DataObject data = DataObject.find(fob);
        data.getLookup().lookup(OpenCookie.class).open();
        data.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(final PropertyChangeEvent evt) {
                if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) {
                    //save item remotely
                    LOG.info(String.format("Saving Report template [%s]", name));
                    saveContent();
                }
            }
        });
    }
}

From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java

/**
 * Creates new form FixedHorizonsGraphView
 *///from w  ww . j a  va  2  s .  c om
public RealTimePerspGraphView(DfmDocument doc) {
    initComponents();

    demetraUI = DemetraUI.getDefault();
    formatter = demetraUI.getDataFormat().numberFormatter();
    defaultColorSchemeSupport = new SwingColorSchemeSupport() {
        @Override
        public ColorScheme getColorScheme() {
            return demetraUI.getColorScheme();
        }
    };

    this.graphs_ = new LinkedHashMap<>();

    trueDataRenderer = new XYLineAndShapeRenderer(true, false);
    trueDataRenderer.setAutoPopulateSeriesPaint(false);
    trueDataRenderer.setBasePaint(defaultColorSchemeSupport.getLineColor(KnownColor.RED));

    forecastsRenderer = new XYLineAndShapeRenderer(true, false);
    forecastsRenderer.setAutoPopulateSeriesPaint(false);
    forecastsRenderer.setAutoPopulateSeriesShape(false);
    forecastsRenderer.setBaseShape(new Ellipse2D.Double(-2, -2, 4, 4));
    forecastsRenderer.setBasePaint(defaultColorSchemeSupport.getLineColor(KnownColor.BLUE));
    forecastsRenderer.setBaseShapesFilled(false);

    arimaRenderer = new XYLineAndShapeRenderer(true, false);
    arimaRenderer.setAutoPopulateSeriesPaint(false);
    arimaRenderer.setAutoPopulateSeriesShape(false);
    arimaRenderer.setBaseShape(new Ellipse2D.Double(-2, -2, 4, 4));
    arimaRenderer.setBasePaint(defaultColorSchemeSupport.getLineColor(KnownColor.GREEN));
    arimaRenderer.setBaseShapesFilled(false);

    mainChart = createChart();
    detailChart = createChart();

    this.dfmSimulation = Optional.absent();

    chartPanel = new JChartPanel(null);
    chartPanel.setPopupMenu(buildMenu().getPopupMenu());

    chartPanel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            indexSelected = -1;
            if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                double x = chartPanel.getChartX(e.getX());
                Graphs g = null;
                for (Bornes b : graphs_.keySet()) {
                    indexSelected++;
                    if (x >= b.min_ && x <= b.max_) {
                        g = graphs_.get(b);
                        break;
                    }
                }
                if (g == null) {
                    return;
                }

                showDetail(g);
            }
        }
    });

    comboBox.setRenderer(new ComboBoxRenderer());
    comboBox.addItemListener((ItemEvent e) -> {
        filterPanel = null;
        updateChart();
    });

    addPropertyChangeListener((PropertyChangeEvent evt) -> {
        switch (evt.getPropertyName()) {
        case DFM_SIMULATION_PROPERTY:
            updateComboBox();
            updateChart();
            break;
        }
    });

    updateComboBox();
    updateChart();

    demetraUI.addPropertyChangeListener((PropertyChangeEvent evt) -> {
        switch (evt.getPropertyName()) {
        case DemetraUI.DATA_FORMAT_PROPERTY:
            onDataFormatChanged();
            break;
        case DemetraUI.COLOR_SCHEME_NAME_PROPERTY:
            onColorSchemeChanged();
            break;
        }
    });

    add(chartPanel, BorderLayout.CENTER);
}

From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java

private void openMailEditor(final String name) throws IOException {
    String formatStr = (String) JOptionPane.showInputDialog(null, "Select File Format", "File format",
            JOptionPane.QUESTION_MESSAGE, null, PluginConstants.MAIL_TEMPLATE_FORMATS,
            MailTemplateFormat.TEXT.name());

    if (StringUtils.isNotBlank(formatStr)) {

        MailTemplateFormat format = MailTemplateFormat.valueOf(formatStr);
        String type = null;/*from   ww w . j a  va2  s.c  om*/
        InputStream is = null;

        try {
            switch (format) {
            case HTML:
                type = "html";
                is = (InputStream) mailTemplateManagerService.getFormat(name, MailTemplateFormat.HTML);
                break;
            case TEXT:
                type = "txt";
                is = (InputStream) mailTemplateManagerService.getFormat(name, MailTemplateFormat.TEXT);
                break;
            default:
                LOG.log(Level.SEVERE, String.format("Format [%s] not supported", format));
                break;
            }
        } catch (SyncopeClientException e) {
            LOG.log(Level.SEVERE,
                    String.format("Unable to get [%s] mail template in [%s] format", name, format), e);
            if (ClientExceptionType.NotFound.equals(e.getType())) {
                LOG.log(Level.SEVERE,
                        String.format("Report template in [%s] format not found, create an empty one", format));
            } else {
                JOptionPane.showMessageDialog(null,
                        String.format("Unable to get [%s] report template in [%s] format", name, format),
                        "Connection Error", JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception e) {
            LOG.log(Level.SEVERE,
                    String.format("Unable to get [%s] mail template in [%s] format", name, format), e);
            JOptionPane.showMessageDialog(null,
                    String.format("Unable to get [%s] mail template in [%s] format", name, format), "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
        String content = is == null ? StringUtils.EMPTY : IOUtils.toString(is, encodingPattern);

        String mailTemplatesDirName = System.getProperty("java.io.tmpdir") + "/Templates/Mail/";
        File mailTemplatesDir = new File(mailTemplatesDirName);
        if (!mailTemplatesDir.exists()) {
            mailTemplatesDir.mkdirs();
        }
        File file = new File(mailTemplatesDirName + name + "." + type);
        FileWriter fw = new FileWriter(file);
        fw.write(content);
        fw.flush();
        FileObject fob = FileUtil.toFileObject(file.getAbsoluteFile());
        fob.setAttribute("description", "TEXT");
        DataObject data = DataObject.find(fob);
        data.getLookup().lookup(OpenCookie.class).open();
        data.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(final PropertyChangeEvent evt) {
                if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) {
                    //save item remotely
                    LOG.info(String.format("Saving Mail template [%s]", name));
                    saveContent();
                }
            }
        });
    }
}

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplicationView.java

/**
 * Creates the tas monitor and exit listeners.
 *///from w  w  w  .  j a v  a  2  s.  c  o m
private synchronized void createTasMonitorAndExitListeners() {

    // connecting action tasks to status bar via TaskMonitor
    taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            String propertyName = evt.getPropertyName();
            if ("started".equals(propertyName)) {
                busyLabel.setBusy(true);
                setTaskRunning(true);
            } else if ("done".equals(propertyName)) {
                busyLabel.setBusy(false);
                progressBar.setVisible(false);
                progressBar.setValue(0);
                setTaskRunning(false);
            } else if ("message".equals(propertyName)) {
                String text = (String) (evt.getNewValue());
                statusMessageLabel.setText((text == null) ? "" : text);
            } else if ("progress".equals(propertyName)) {
                int value = (Integer) (evt.getNewValue());
                busyLabel.setBusy(false);
                progressBar.setVisible(true);
                progressBar.setIndeterminate(false);
                progressBar.setValue(value);
            } else if ("cancel".equals(propertyName)) {
                statusMessageLabel.setText("Task cancelled");
            }
        }
    });

    // add exit listener
    Application.ExitListener exitListener = new Application.ExitListener() {

        private boolean canExit = false;

        public boolean canExit(EventObject e) {

            canExit = checkCanExit();
            logger.info("Value of canExit : " + canExit);
            return canExit;
        }

        public void willExit(EventObject e) {
            // clean up before exiting
            cleanUpBeforeExit();

            // save to log
            logger.info("Shutting down application");
        }
    };
    getApplication().addExitListener(exitListener);

    // add window listener
    getFrame().addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent windowEvent) {
            // call exit listener
            getApplication().exit();
        }
    });
}

From source file:edu.ku.brc.specify.ui.DBObjSearchPanel.java

public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("selection")) {
        Integer numRowsSelected = (Integer) evt.getOldValue();
        if (numRowsSelected > 0) {
            idList = etrb.getListOfIds(false);
        } else {//w  ww  . java 2  s  .  c  om
            idList = null;
        }
        updateUIControls();

    } else if (evt.getPropertyName().equals("doubleClick")) {
        okBtn.doClick();

    } else if (evt.getPropertyName().equals("loaded")) {
        // If there is only one returned, then select it and focus the OK defult btn
        if (evt.getNewValue() != null && ((Integer) evt.getNewValue()) == 1) {
            ESResultsTablePanel etrbPanel = (ESResultsTablePanel) etrb;
            etrbPanel.getTable().setRowSelectionInterval(0, 0);
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    okBtn.requestFocus();
                }
            });

        }
    }
}

From source file:e3fraud.gui.MainWindow.java

public void actionPerformed(ActionEvent e) {

    //Handle open button action.
    if (e.getSource() == openButton) {
        int returnVal = fc.showOpenDialog(MainWindow.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //parse file
            this.baseModel = FileParser.parseFile(file);
            log.append(currentTime.currentTime() + " Opened: " + file.getName() + "." + newline);
        } else {//from   www  .  j  a va  2 s .  com
            log.append(currentTime.currentTime() + " Open command cancelled by user." + newline);
        }
        log.setCaretPosition(log.getDocument().getLength());

        //handle Generate button
    } else if (e.getSource() == generateButton) {
        if (this.baseModel != null) {
            //have the user indicate the ToA via pop-up
            JFrame frame1 = new JFrame("Select Target of Assessment");
            Map<String, Resource> actorsMap = this.baseModel.getActorsMap();
            String selectedActorString = (String) JOptionPane.showInputDialog(frame1,
                    "Which actor's perspective are you taking?", "Choose main actor",
                    JOptionPane.QUESTION_MESSAGE, null, actorsMap.keySet().toArray(),
                    actorsMap.keySet().toArray()[0]);
            if (selectedActorString == null) {
                log.append(currentTime.currentTime() + " Attack generation cancelled!" + newline);
            } else {
                lastSelectedActorString = selectedActorString;
                //have the user select a need via pop-up
                JFrame frame2 = new JFrame("Select graph parameter");
                Map<String, Resource> needsMap = this.baseModel.getNeedsMap();
                String selectedNeedString = (String) JOptionPane.showInputDialog(frame2,
                        "What do you want to use as parameter?", "Choose need to parametrize",
                        JOptionPane.QUESTION_MESSAGE, null, needsMap.keySet().toArray(),
                        needsMap.keySet().toArray()[0]);
                if (selectedNeedString == null) {
                    log.append("Attack generation cancelled!" + newline);
                } else {
                    lastSelectedNeedString = selectedNeedString;
                    //have the user select occurence interval via pop-up
                    JTextField xField = new JTextField("1", 4);
                    JTextField yField = new JTextField("500", 4);
                    JPanel myPanel = new JPanel();
                    myPanel.add(new JLabel("Mininum occurences:"));
                    myPanel.add(xField);
                    myPanel.add(Box.createHorizontalStrut(15)); // a spacer
                    myPanel.add(new JLabel("Maximum occurences:"));
                    myPanel.add(yField);
                    int result = JOptionPane.showConfirmDialog(null, myPanel,
                            "Please Enter occurence rate interval", JOptionPane.OK_CANCEL_OPTION);

                    if (result == JOptionPane.CANCEL_OPTION) {
                        log.append("Attack generation cancelled!" + newline);
                    } else if (result == JOptionPane.OK_OPTION) {
                        startValue = Integer.parseInt(xField.getText());
                        endValue = Integer.parseInt(yField.getText());

                        selectedNeed = needsMap.get(selectedNeedString);
                        selectedActor = actorsMap.get(selectedActorString);

                        //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI)
                        GenerationWorker generationWorker = new GenerationWorker(baseModel, selectedActorString,
                                selectedActor, selectedNeed, selectedNeedString, startValue, endValue, log,
                                lossButton, gainButton, lossGainButton, gainLossButton, groupingButton,
                                collusionsButton) {
                            //make it so that when Worker is done
                            @Override
                            protected void done() {
                                try {
                                    progressBar.setVisible(false);
                                    System.err.println("I made it invisible");
                                    //the Worker's result is retrieved
                                    treeModel.setRoot(get());
                                    tree.setModel(treeModel);

                                    tree.updateUI();
                                    tree.collapseRow(1);
                                    //tree.expandRow(0);
                                    tree.setRootVisible(false);
                                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                                } catch (InterruptedException | ExecutionException ex) {
                                    Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
                                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                                    log.append("Out of memory; please increase heap size of JVM");
                                    PopUps.infoBox(
                                            "Encountered an error. Most likely out of memory; try increasing the heap size of JVM",
                                            "Error");
                                }
                            }
                        };
                        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        progressBar.setVisible(true);
                        progressBar.setIndeterminate(true);
                        progressBar.setString("generating...");
                        generationWorker.addPropertyChangeListener(new PropertyChangeListener() {
                            public void propertyChange(PropertyChangeEvent evt) {
                                if ("phase".equals(evt.getPropertyName())) {
                                    progressBar.setMaximum(100);
                                    progressBar.setIndeterminate(false);
                                    progressBar.setString("ranking...");
                                } else if ("progress".equals(evt.getPropertyName())) {
                                    progressBar.setValue((Integer) evt.getNewValue());
                                }
                            }
                        });
                        generationWorker.execute();
                    }
                }
            }
        } else {
            log.append("Load a model file first!" + newline);
        }
    } //handle the refresh button
    else if (e.getSource() == refreshButton) {
        if (lastSelectedNeedString != null && lastSelectedActorString != null) {
            Map<String, Resource> actorsMap = this.baseModel.getActorsMap();
            Map<String, Resource> needsMap = this.baseModel.getNeedsMap();
            selectedNeed = needsMap.get(lastSelectedNeedString);
            selectedActor = actorsMap.get(lastSelectedActorString);

            //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI)
            GenerationWorker generationWorker = new GenerationWorker(baseModel, lastSelectedActorString,
                    selectedActor, selectedNeed, lastSelectedNeedString, startValue, endValue, log, lossButton,
                    gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) {
                //make it so that when Worker is done
                @Override
                protected void done() {
                    try {
                        progressBar.setVisible(false);
                        //the Worker's result is retrieved
                        treeModel.setRoot(get());
                        tree.setModel(treeModel);
                        tree.updateUI();
                        tree.collapseRow(1);
                        //tree.expandRow(0);
                        tree.setRootVisible(false);
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    } catch (InterruptedException | ExecutionException ex) {
                        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                        log.append("Most likely out of memory; please increase heap size of JVM");
                        PopUps.infoBox(
                                "Encountered an error. Most likely out of memory; try increasing the heap size of JVM",
                                "Error");
                    }
                }
            };
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            progressBar.setVisible(true);
            progressBar.setIndeterminate(true);
            progressBar.setString("generating...");
            generationWorker.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    if ("phase".equals(evt.getPropertyName())) {
                        progressBar.setMaximum(100);
                        progressBar.setIndeterminate(false);
                        progressBar.setString("ranking...");
                    } else if ("progress".equals(evt.getPropertyName())) {
                        progressBar.setValue((Integer) evt.getNewValue());
                    }
                }
            });
            generationWorker.execute();

        } else {
            log.append(currentTime.currentTime() + " Nothing to refresh. Generate models first" + newline);
        }

    } //handle show ideal graph button
    else if (e.getSource() == idealGraphButton) {
        if (this.baseModel != null) {
            graph1 = GraphingTool.generateGraph(baseModel, selectedNeed, startValue, endValue, true);//expected graph 
            ChartFrame chartframe1 = new ChartFrame("Ideal results", graph1);
            chartframe1.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT));
            chartframe1.pack();
            chartframe1.setLocationByPlatform(true);
            chartframe1.setVisible(true);
        } else {
            log.append(currentTime.currentTime() + " Load a model file first!" + newline);
        }
    } //Handle the graph extend button//Handle the graph extend button
    else if (e.getSource() == expandButton) {
        //make sure there is a graph to show
        if (graph2 == null) {
            log.append(currentTime.currentTime() + " No graph to display. Select one first." + newline);
        } else {
            //this makes sure both graphs have the same y axis:
            //            double lowerBound = min(graph1.getXYPlot().getRangeAxis().getRange().getLowerBound(), graph2.getXYPlot().getRangeAxis().getRange().getLowerBound());
            //            double upperBound = max(graph1.getXYPlot().getRangeAxis().getRange().getUpperBound(), graph2.getXYPlot().getRangeAxis().getRange().getUpperBound());
            //            graph1.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound);
            //            graph2.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound);
            chartPane.removeAll();
            chartPanel = new ChartPanel(graph2);
            chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT));
            chartPane.add(chartPanel);
            chartPane.add(collapseButton);
            extended = true;
            this.setPreferredSize(new Dimension(this.getWidth() + CHART_WIDTH, this.getHeight()));
            JFrame frame = (JFrame) getRootPane().getParent();
            frame.pack();
        }
    } //Handle the graph collapse button//Handle the graph collapse button
    else if (e.getSource() == collapseButton) {
        System.out.println("resizing by -" + CHART_WIDTH);
        chartPane.removeAll();
        chartPane.add(expandButton);
        this.setPreferredSize(new Dimension(this.getWidth() - CHART_WIDTH, this.getHeight()));
        chartPane.repaint();
        chartPane.revalidate();
        extended = false;
        JFrame frame = (JFrame) getRootPane().getParent();
        frame.pack();
    }
}