graph.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
JFrame popupFrame = new JFrame();
final DistributionDensityGraph popupGraph = new DistributionDensityGraph(sop.getDist());
popupGraph.setToolTipText("Right click to 'Save As'.");
popupFrame.getContentPane().add(popupGraph);
popupFrame.setTitle(windowName);
popupFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int width = 640, height = 480;
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
popupFrame.setBounds((scrDim.width - width) / 2, (scrDim.height - height) / 2, width, height);
popupGraph.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
popupGraph.mouseClicked(e);
}
});
popupFrame.setVisible(true);