• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getParameter() in a Swing applet

 
Tony Costa
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?
 
Manfred Leonhardt
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic