File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes simple applet won't run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "simple applet won Watch "simple applet won New topic
Author

simple applet won't run

John Davis
Ranch Hand

Joined: Nov 02, 2000
Posts: 189
I coded up a simple applet and some html with an applet tag and it tested out OK using the applet viewer. But it doesn't do anything (except draw a grey empty box 100x200) when executed from the application server.
For the applicaton server test, I put the applet tag in the HTML Body of the JSP page i.e.
<applet code=CatApplet.class height=100 width=200> </applet>
The applet class file is in the same directory as the JSP page. The source for it is:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
import java.util.Date;
public class CatApplet extends JApplet
{
public void init ()
{
setBackground(Color.green);
resize (250,100);
}

public void paint (Graphics g)
{
g.drawString ("lets get some cat gui going", 35, 15);
}
}
Why won't my applet run when the applet tags are in the JSP page?
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Doesn't have anything to do with the JSP, it has to do with you using Swing (JApplet). Regular <applet...></applet> tags don't work, you need to run it through an HTML Converter.
My suggestion, create an HTML file first with
<HTML>
<applet...></applet>
</HTML>
Run the HTML Converter over that HTML file, then cut and past what is added to the HTML file into your JSP.
Either that, or make sure your browser has the latest plugin that can view Swing. Never gotten this to work, but some people have I believe.
There is a JSP plug-in tag that allows you to download the plugin from whatever source to the browser that is trying to run the applet, could use that in your JSP and make it more portable and not having to rely on the browser configuration.
Jack Robin
Greenhorn

Joined: Sep 24, 2014
Posts: 4
i tried its not working
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

ItDoesntWorkIsUseless.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18643
    
    8

Advice about applets from 2002 is also useless. So if you have an applet problem, Jack, and you can't find current (i.e. within the last year) advice about it, I would suggest asking a question here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: simple applet won't run