• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing parameter to applet

 
karthik muthuveeramani
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i run the following code i invariably get a null pointer exception please help me out.
import java.awt.*;
import java.applet.*;
/*<applet code="MyApplet.class" width=200 height=300>
<param name="message" value="hello world">
</applet>
*/
public class MyApplet extends Applet
{
String uuu;
public void init()
{
uuu=getParameter("message");
}
public void start()
{
repaint();
}
public void paint(Graphics g)
{
/*if(getParameter("message")==null)
{
g.drawString( "",20,20);
}
else*/
g.drawString(uuu ,20,20);
}
}//end applet
 
Angela Jessi
Ranch Hand
Posts: 428
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthik,
Don't use start method. Just use Init and Paint method.
Thanks,
Angela
 
karthik muthuveeramani
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi angela
thanks for your reply. i tried it but strangely its not working.
pl help me.
thanks once again
karthik
 
Angela Jessi
Ranch Hand
Posts: 428
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Karthik,
Here is code:
import java.applet.Applet;
import java.awt.*;

public class MyApplet extends Applet
{
String uuu;
public void init()
{
uuu=getParameter("message");
}
public void paint(Graphics g)
{
g.drawString(uuu ,20,20);
}
Here is HTML file:
<html>
<head>
<title>Card Test (1.1)</title>
</head>
<body>
<applet code=MyApplet.class width=500 height=900>
<param name="message" value="hello world">
</applet>
</applet>
</body>
</html>
It is working!
Let me know further help,
Thanks
angela
 
venkataraman bagavathisub
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am karthik's friend.
thank you angela the code is working .i actually had a ie-jvm problem.got alright after reinstalling it(windows jvm).
this is actually for a ticker tape.its moving very slowly even if i adjust the Thread.sleep to 10(Thread.sleep(10)).i will be looking for answers , meanwhile you also pass suggestions.
thanking you
karthik
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make the scrolling move faster, increase the x ( or y ) amount that you are moving the text each time. This will make a much bigger difference than increasing the Thread speed...

-Nate
 
mohana konakanchi
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am using JDK1.3,
I have to pass arguments to Applet.
I am using html converted file from JDK1.3 HTML converter.
I am getting parameter in IE. but Netscape returning null
I tryed use getParameter in init(), start() also.
both the cases Netscape is failing to get the parameter
any help?
thanks in advance
Mohana
 
ruilin yang
Ranch Hand
Posts: 334
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you guys know how to pass an array of values to an Applet ?
I mean one parameter name, the value of the parameter is an array (e.g. 10000 elements).
Please comments if you have ideas on how to do it.
Thanks
Ruilin
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic