I have two classes. One (class1) extends JApplet and other (say, class2) extends JPanel. I use class2 to create a panel in class1 (JPanel p = new Class2() ). I have a button in class2. When the user clicks the button, in actionPerformed, i call applet method using applet object (class1 c1 = new class1; c1.myMethod() ). In myMethod, i use some of the variables defined globally. this variable are set in the init() method of class1. but, when I call myMethod and access these variable, I get null values. why are these variables null? I define -- String x = null; and in init() I do -- x ="someValue"; when I print the x value in myMethod, it prints null. Any thoughts?