I am developing using Java SE on NetBeans 7.3.1 on Windows 7.
My java main method has the following calls
static Vector<Point2D> acceptedByFilter, coords;
// Some code to read the coords from a file
// Some code to filter coords and produce a subset called acceptedByFilter
DisplayInputPoints();
DisplayPointsAcceptedByFilter();
These methods are defined as follows
static protected void DisplayPointsAcceptedByFilter(){
Panel panel=new Panel();
panel.DisplayInputPoints(acceptedByFilter, xMin, xMax, yMin, yMax, true, "Points accepted by filter");
}
static void DisplayInputPoints(){
Panel panel=new Panel();
panel.DisplayInputPoints(coords, xMin, xMax, yMin, yMax, true, "Original Points");
}
Panel.DisplayInputPoints is defined as follows
import javax.swing.JFrame;
import javax.swing.JPanel;
public
class Panel extends JPanel
{
public static void DisplayInputPoints(Vector<Point2D> coords, double xMin, double xMax, double yMin,
double yMax, boolean invert, String label){
JFrame frame = new JFrame(label);
Panel panel = new Panel();
panel.setPreferredSize(new Dimension((int)Math.round(xMax-xMin) + 10,
(int)Math.round(yMax-yMin) + 10));
panel.loadPoints(coords);
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
frame.repaint();
}
}
When I call
DisplayInputPoints();
the first frame appears and it displays the points in the coords vector. When I call
DisplayPointsAcceptedByFilter();
I get another frame and the points in the acceptedByFilter appear in both frames. That is, the first frame gets overwritten by the display that is in the second frame.
What is the best way to stop the first frame being overwritten by what is supposed to be only in the second frame?