Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

accessing applet variable outside the applet

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
    Bookmark Topic Watch Topic
  • New Topic