Page 621 - Introduction to Programming with Java: A Problem Solving Approach
P. 621

                14.13 GUI Track and Problem Solving: Line Plot Example Revisited (Optional) 587
 /****************************************************************
*
LinePlotGUI.java
Dean & Dean
This program plots a line as a sequence of connected,
user-specified points.
****************************************************************/
*
*
*
*
import javax.swing.*; // for JFrame, JOptionPane
public class LinePlotGUI extends JFrame
{
private static final
private static final
private static final
int numOfPoints
int maxY;
double[] yCoords;
int FRAME_WIDTH = 400;
int FRAME_HEIGHT = 250;
int MARGIN = 20; // space between frame
// and line plot
// points go from N=0 to N=numOfPoints-1
// y coordinate values go from y=0 to y=maxY
// y coordinate values for all the points
//*************************************************************
public LinePloAtpGUaI(g)o PDF Enhancer {
setSize(FRAME_WIDTH, FRAME_HEIGHT);
setTitle("Line Plot");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// end LinePlotGUI
//*************************************************************
}
int getMargin()
{
}
return MARGIN;
int getMaxY()
{
}
return maxY;
double[] getYCoords()
{
}
return yCoords;
Figure 14.20a
LinePlotGUI class—part A

















































   619   620   621   622   623