Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

getParameter() in a Swing applet

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is getParameter() supported in a Swing applet. It compiles fine, but when it runs it throws a NullPointerException. This is how I am using it:
String s = getParameter("test");
If it is not supported in Swing applets, how do you get access to parameters that have been passed in?
Also, are there any good resources on the web that talk about differences between developing Swing applets vs. standard (AWT) applets?
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,
Whatever you may think about Swing it doesn't limit the AWT approach it expands it. The line you show in your post won't throw a null pointer exception. If you are trying to use the variable s once it is assigned null then you can get the error. You should always check the result of getParameter() to make sure you actually get something useful.
Regards,
Manfred.
 
Tony Costa
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am aware that not checking for null will throw a NullPointerException. I'm just testing to see if it works at this point.
The problem is not with my code, but somewhere in the applet code. The stack trace says the NullPointerException was thrown at java.applet.Applet.getrParameter(Applet.java:128).
Tony.
 
Tony Costa
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out. I was calling it in the constructor and not the init method. For some reason Forte for Java doesn't have the init, start, stop, and destroy methods added to their JApplet template, but does add them to the Applet template. I knew something dumb was missing...
Tony
 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic