• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

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?
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic