aspose file tools*
The moose likes Applets and the fly likes put an applet into a web page    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "put an applet into a web page    " Watch "put an applet into a web page    " New topic
Author

put an applet into a web page

Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
Hi, my codes works well in NetBeans as an applet, but why no appearance in a html.

One thing I must mention is I create my code that works both as an applet and as a stand-alone application.
I have three class: Combox.java ,Drawing.java and TextCell.java.
The code structure looks like
Thanks for any help.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
The HTML tag is called "applet", not "Japplet".


Ping & DNS - my free Android networking tools app
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
I have changed, but only a retcange frame showed, no any components.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Are there any messages in the browser status bar, or the Java Console?
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
No, but in my class "TestCell", File I/O indeed exists.
Is the reason or not?

Thanks
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
One thing I forget is:
Press Spacebar or Enter to activate this control
activate the control is to click inside the border of the applet.
But I click anywhere, nothing.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Do applets work in general, e.g. the ones on this page? Can you try it with a different browser than IE?
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
All the examples works well except mine.
I tried them in IE and Firefox.
Dawn!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Does the applet contain code that actually shows something? I'm asking because the code you posted does not seem to do anything graphical.
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
ok,first thanks for your nice reply.Then my code is:
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
The error from Java console is
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Applets are not allowed to do file I/O, unless they are signed, or the local security policy altered. That's what's causing this exception. See HowCanAnAppletReadFilesOnTheLocalFileSystem for more details.
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
yes,I am doing a self-signed certificate, I followed an example on the web.
But I got wrong at some step. Any help, thanks.
Where is the file migsuncert.crt located?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Originally posted by Hui Zhao:
Where is the file migsuncert.crt located?

C:\Program Files\Java\jdk1.6.0_01\bin>keytool -export -alias migkey -file migsuncert.crt
Enter keystore password:
keytool error: java.io.FileNotFoundException: migsuncert.crt (Access is denied)


The filename is used for the certificate file you're trying to export to; it doesn't exist yet. Does the account you're using possibly not have write permissions for that directory? That's another reason for that exception to happen.
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
I signed successfully in another machine.
And I follow the instructions in the book "Java Cookbook".
You can now sign the JAR file with your test certificate:

The jarsigner tool updates the META-INF directory of your JAR file to
contain certificate information and digital signatures for each entry in the archive.
Now I have two questions.
1)What is meant by the term "META-INF" directory?
2)Because my applet contains File I/O, after this step can I run my applet?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
What is meant by the term "META-INF" directory?

Jar files contain a META-INF directory which in most cases contains just a single file: the manifest. In it you'll find various pieces of meta information about the jar file, including information about its signature. That's why it is updated if the jar file is signed. The jar file specification has more details on this.
Because my applet contains File I/O, after this step can I run my applet?

It should run. Have you tried it?
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
okay,it works well.
One more question:why the height is 0, how can I set it?

Thank you very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: put an applet into a web page