> Why don't you supply an SSCCE* of what your doing.
>> The other group is better for people who are just starting in
>> Java, and (one would hope that) anyone who is unable to do
>> something this straightforward is just starting in Java.
>
> I haven't been programming in JAVA
Technically, it is Java (a name, rather than a capitalised acronym).
>.. for more than 3 months so you are
> assuming right. So I will keep future questions in the java.help group.
That would probably be best until you get the hang of the groups,
though you seem to be doing that rather quickly.
>> Why don't you supply an SSCCE* of what your doing.
>
> Look at my response to VisionSet. I feel its an SSCCE
Close. Note that you could move all the imports to the top,
demote the second class to 'default' (see code) and compile it
all in the same file.
>..besides the fact that
> it wont compile. But thats the problem I am having.
Look closely at the comments I put in, they explain further..
<sscce>
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class ProgramSetup
{
private double temp;
private Random random;
private int[] yvalues;
private int[] xvalues;
/** For sticking with my original advice, I'll add two
arrays of arrays. */
private int[][] shape1;
private int[][] shape2;
private int times = 750;
/** this is actually a sub-class of JPanel. If you declare
it as an JPanel, Java will assume that only JPanel methods
are present, rather than the extra ones you defined for
setShapes() etcetera. */
// private JPanel primaryPanel;
private DrawPanel primaryPanel;
public ProgramSetup()
{
makeGUI();
}
public void calculate()
{
random = new Random();
xvalues = new int[times];
yvalues = new int[times];
shape1 = new int[2][];
shape1[0] = xvalues;
shape1[1] = yvalues;
shape2 = new int[2][];
shape2[0] = xvalues;
shape2[1] = yvalues;
temp = 0;
for(int j = 0; j != times; j++)
{
xvalues[j] = j;
}
for(int j = 0; j != times; j++)
{
yvalues[j] = (int) (temp - 1 - 5 * random.nextGaussian());
temp = yvalues[j];
}
primaryPanel.setShapes(shape1, shape2);
}
public void makeGUI()
{
JFrame frame = new JFrame("Graph");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
primaryPanel = new DrawPanel();
frame.getContentPane().add(primaryPanel);
frame.pack();
frame.setVisible(true);
}
}
class DrawPanel extends JPanel
{
private int[] xvalues;
private int[] yvalues;
private int times;
int[][] shape1, shape2;
public DrawPanel()
{
setup();
}
/** Note that this method currently accepts two arrays of
arrays (often referred to as multi-dimensional arrays).
It might make more sense to hand two single arrays of
Point objects. Each Point object possesses an x and y
attribute. Though that is another story. */
public void setShapes(int[][] shape1, int[][] shape2)
{
this.shape1 = shape1;
this.shape2 = shape2;
}
public void setup()
{
setPreferredSize(new Dimension(800,450));
setBackground(Color.red);
}
public void paintComponent(Graphics e)
{
super.paintComponent(e);
e.translate(50,400);
e.setColor(Color.white);
if (xvalues!=null)
{
e.drawPolyline(xvalues, yvalues, xvalues.length);
}
}
}
</sscce>
HTH

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
CR - 28 Nov 2004 22:59 GMT
Thanks a lot. Your comments were very useful and I finally got it working.
Andrew Thompson - 29 Nov 2004 04:33 GMT
> Thanks a lot. Your comments were very useful and I finally got it working.
You're welcome. Glad you got it sorted.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane