Hi everyone,

im doing this question:

(1) Find the errors in the applet given below and re-write it after correcting the errors.

import java.awt.*;
import java.applet.*;
 
 public class appError extends Applet{
 String name; public void paint()
{ 
Font font=new Font(“Monospaced”, Font.ITALIC, 36);
 setFont(font); 
setBackground(yellow);
 setColor(red); drawstring(name); 
}//end of paint()
}//end of class

I managed to correct the code to this:

import java.awt.*;
import java.applet.*;
import java.awt.FlowLayout;
 
public class MidTerm1 extends Applet{
String name;
 
public void paint(Graphics g){
Font font=new Font("Monospaced", Font.ITALIC, 36);
setFont(font);
setBackground(Color.yellow);
g.setColor(Color.red);
g.drawString("manal", 10, 100);
}//end of paint()

The problem is that im having problems with the second part of the question which is:
Write appropriate HTML statements to provide a value for the variable name at the time of running the applet. Include the appropriate statement(s) in the applet to read values from the HTML statements.

i have no clue on how i can start it off. Is it ok if you only give me tips on how i can start it off.

Thank you soooo much!!

Every decent tutorial about applets should have that information.
Several of the demonstration applets that ship with the JDK also use parameters.

Member Avatar for iamthwee

Write appropriate HTML statements to provide a value for the variable name at the time of running the applet. Include the appropriate statement(s) in the applet to read values from the HTML statements.

Sounds like a html problem. A good book will give an example of combining a java applet and html.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.