import javax.swing.*; import java.awt.*; /** * DrawingPanel creates a panel used for drawing * a map **/ class DrawingPanel extends JPanel { private Graphics g; //used for drawing on the panel private boolean timeToDrawPath = false; private String pathFile = null; public DrawingPanel() { setBackground(Color.white); //for drawing the maps } public void paint(Graphics grph) { g = grph; super.paint(g); processUSA(); if (timeToDrawPath) drawPath(); } /** * processUSA() draws line segments to create * the map of the USA **/ public void processUSA() { g.drawLine( 50, 50, 200, 200); //just an example of how to draw // a single line segment from (50,50) // to (200,200) } /** * processPath receives the file name containing the * coordinates for the hurricane path * * @param String filename file containing the coordinates for * the line segments that produce * the path of the hurricane **/ public void processPath(String filename) { // complete method pathFile = filename; timeToDrawPath= true; //used in paint() repaint(); } /** * drawPath() uses the (x,y)coordinates in the file specified * by pathFile to draw the line segments for the hurricane path * **/ private void drawPath() { g.drawLine( 115,125,10,150); // another example of how to draw } }