Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

loading applet on web browser

hi!

I am trying to load applet on web browser.
I placed HelloApplet.class and HelloApplet.html same dir(home_dir/public_html/../..).
However, when I tried to load by typing "http://www....../HelloApplet.html,
just "Hello, Applet World!" from HelloApplet.html file appears, and there is
no string or clickable button on the browser. It just shows gray area...that's it.
Why is that?

Thanks for help.

//---------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class HelloApplet extends JApplet {

   private int currentIndex = 0;
   
   public void init() {
      final String[] MESSAGES = {"Hello, Applet World!","Still here"};
      final JLabel DISPLAY_LABEL = new JLabel("");
      JButton showButton = new JButton("Click here for a message " +
                                 "from our sponsor!");
      showButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            DISPLAY_LABEL.setText(MESSAGES[currentIndex]);
            currentIndex = (currentIndex + 1) % MESSAGES.length;
         }
      });
      Container contentPane = getContentPane();
      contentPane.add(showButton, BorderLayout.NORTH);
      contentPane.add(DISPLAY_LABEL, BorderLayout.CENTER);
   }
}

//-------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title>Hello, Applet World!</title>
</head>
<body>
<h1>Hello, Applet World!</h1>
<br>

<applet code="HelloApplet.class" width="400" height="100">
Error, your browser does not understand applet tags!
</applet>

</body>
</html>
SOLUTION
Avatar of dualsoul
dualsoul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkim18
dkim18

ASKER

Thank you for your answer, but I don't see Enable Java Plug-in option on Basic Panel and any other panel.
Avatar of TimYates
The "Advanced" panel?

It's about half way down the list of checkboxes
Sorry...

Tools -> Internet Options -> Advanced
Of course, you will need the plugin from http://java.sun.com/getjava if you don't already have it...
Avatar of dkim18

ASKER

I tried all, but it wasn't successful. I don't know why...
When I try to run, I see "java.lang.NoClassDefFoundError:HelloApplet$1." on bottom of web broswer.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkim18

ASKER

I ftp HelloApplet$1.class as well and the applet starts, but I still don't see clickable button and messages"
What is difference "HelloApplet$1.class" and "HelloApplet.class"? When I compiled, I got both classes file.
There is no inner class in my applet by the way.(from above source)

I 'd apprecatied your comments
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkim18

ASKER

It shows up "Hello, Applet World!" and the bottom web broswer says 'Applet HelloApplet Started and then if I mouse my mouse to gray box then the msg chagnes to 'loading java applet...' and it takes forever.  I did try CTRL-Refresh option, but didn't work.
Is it server problem? I asked to a friend of mine to load the applet and he got same problem...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial