I have two .java's one called GUI.java, another called CustomPanel.java
Once a button is pressed in GUI.java, it does some stuff:
if (e.getSource() == displayButton)
{
//pageviews1 = Integer.parseInt(myText1.getText());
CustomPanel cp = new CustomPanel();
Graphics g = loginMainPanel.getGraphics();
int pos = 0;
while (pos <= 9)
{
if (values[pos] > biggestvalue)
{
biggestvalue = values[pos];
}
pos = pos + 1;
}
cp.test(g, values[0], values2[0], "1", biggestvalue);
cp.test(g, values[1], values2[1], "2", biggestvalue);
cp.test(g, values[2], values2[2], "3", biggestvalue);
cp.test(g, values[3], values2[3], "4", biggestvalue);
cp.test(g, values[4], values2[4], "5", biggestvalue);
cp.test(g, values[5], values2[5], "6", biggestvalue);
cp.test(g, values[6], values2[6], "7", biggestvalue);
cp.test(g, values[7], values2[7], "8", biggestvalue);
cp.test(g, values[8], values2[8], "9", biggestvalue);
cp.test(g, values[9], values2[9], "10", biggestvalue);
//System.out.println("Added Data: " + values2[count2]);
//count2++;
graphlink.setEnabled(true);
}
You don't really need to know what except cp.test; (It does alot but i've condensed it to fit my problem)
public void test(Graphics g, int pageviews2, String date2, String extcount5, int maxint)
{
...
critxvalues[0] = calc;
crityvalues[0] = desty;
System.out.println(critxvalues[0] + ":" + crityvalues[0]);
}
Then once another button is pressed in GUI.java something else happens:
CustomPanel cp = new CustomPanel();
cp.tooltip(x,y);
This cp.tooltip is simply:
public void tooltip(int x, int y)
{
System.out.println(critxvalues[0] + ":" + crityvalues[0]);
}
Which I hoped would print out the same values as when the array[0] is printed out before, but it doesn't cp.tooltip only prints out 0:0, while cp.test prints out (example) 200:200, so why is the:
critxvalues[0] = calc;
crityvalues[0] = desty;
(in cp.test) not saving the values?
The critxvalue/crityvalue is initalised at the top of CustomPanel.java...
int [] critxvalues = new int[100];
int [] crityvalues = new int[100];
Please help,
Thanks.