0

Hi, I am having a challenge with this.. I just read a book on Java Applet and there is something that is confusing to me. i need help on that..

There are two programs here...

import java.awt.Graphics;
import java.swing.JApplet;

public class TryMe extends JApplet {

public void paint (Graphics g)
{
super.paint(g);

g.drawString ("Welcome", 350, 100)
}

}

The other one is :

<HTML>
<Applet Code="TryMe.class">
<\JApplet>
<\HTML>

Where am i going to save the second code and also how exactly do i execute this code so that i can see the string on my Browser of AppletViewer?

Thanks

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Dhruv Gairola
0

there are a number of errrors here:
1. its

import javax.swing.JApplet;

NOT

import java.swing.JApplet;

.
2. theres a missing ; after your drawString
3. your HTML file shouldnt have the <JApplet> tag. Use <applet> instead. And remember to open and close your tags.
4. when closing tags, it shouldnt be <\HTML> it should be </HTML>

the second code will be saved in a .html file, in the same directory as your .class file (which you have to obviously compile first).

Edited by Dhruv Gairola: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.