We help IT Professionals succeed at work.

Why this applet does not show up when run the web page?

somits
somits used Ask the Experts™
on
Hi:

We're writing some Java applet code and embed them into web pages.
We successfully compiled the java applet.
We placed the class file ( of the java applet file) in the same folder where the html file is.

For some reason,the applet  does not show up.

We tried everything to find out where is the problem but could not.

If you've some idea about this problem, please help.

We attached the code, both the applet and the web page below.

Thanks a lot for any help,

Somits

//---------------------- Java applet code

import javax.swing.JApplet;
import java.awt.*;

public class JDisplayApplet extends JApplet {

      /**
       * Create the applet.
       */
      public JDisplayApplet() {

      } // End of public JDisplayApplet
      
      
      public void paint( Graphics g ) {
            
            g.setColor(Color.black);
          g.drawString( "Hello World", 60, 50 );
          g.setColor(Color.red);
          g.drawOval(40,30,120,30);
        }

} // End of public class JDisplayApplet


//---------------------- web page code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Web Page to illustrate Java Applet </title>

</head>
<body>

<div >
<APPLET CODE="JDisplayApplet.class" WIDTH="800" HEIGHT="500"></APPLET>
</div>

</body>
</html>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
Enable the applet console via the Control Panel. If you can't, it suggests you don't have the Java plugin installed correctly (or at all) for your browser
Top Expert 2016

Commented:
:)