• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

passing parameter to applet

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic