Ok, Ive built some overly complex programs, and lately ive been trying to OOP more, making things neater, but ive run into my first OOP problem! Ive made a demonstration program, here it is!
Java Objects:
Panel1.javaCode:[B]Main.java[/B]
[CODE]
package vtest1;
class Main{
public static void main(String[] args) {
Panel2 p2 = new Panel2();
p2.setup();
}
}
Panel2.javaCode:package vtest1;
public class Panel1 {
public void intTest() {
Panel2 p2 = new Panel2();
int x = p2.x;
int y = p2.y;
[COLOR="Blue"]System.out.println(x+","+y);[/COLOR]
}
}
[/CODE]Code:package vtest1;
public class Panel2 {
int x;
int y;
public void setup(){
Panel1 p1 = new Panel1();
x = 10;
y = 10;
print();
p1.intTest();
}
public void print(){
[COLOR="Red"]System.out.println(x+","+y);[/COLOR]
}
}
The first output (Highlighted in red) prints the x and y, so it prints 10,10.
The second output (Highlighted in blue) SHOULD print the x,y (10,10) also! but it doesn't, instead it prints 0,0.
My problem is that my x,y veritable values are not being recognized in my panel1 object!? please help!

