• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Window in Applet

 
trupti
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I've craeted one window in applet using following code
JWindow w = new JWindow();
w.getContentPane().setLayout(new FlowLayout());
w.setSize(600,100);
w.setLocation(200,200);
w.setVisible(true);
But when the applet runs at the bottom of the window it shows message in yellow bar 'Warning applet window'.
Could anybody please tell me how to rempve this? And how to show a simple window?
thanks in advance.
Trupti
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The warning is due to the security sandbox the applets must deal with. The only way to get rid of it is to make your applet a trusted entity. To do this you'll have to package you classes up in a jar file and then 'sign' it. Now, when the applet is launched, the user will be prompted to download the jar file and whether or not it is to be trusted. If they do so, the warning should be removed. Another option might be to use Sun's Java Plugin, which runs outside of the browser and isn't so restrictive when running applets. One other solution I've seen recently (though I havn't tried it) is to create a small frame (which will have the warning) and then have this frame create another frame overtop of the first one. If I recall correctly, the second one won't have the warning. I hope this helps.
Sean
 
trupti
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Sean.
But I don't know how to package the class up in a jar file and how to 'sign' it? Could you please explain it in detail?
Many Thanks
Trupti
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To create a jar file you use the command
jar cf myJar.jar MyClass.class MyClass2.class
This will create a jar called myJar.jar with the classes MyClass.class MyClass2.class in it. Have a look here
http://www.site.uottawa.ca/~kavanagh/LAKE/SunJavaTutorial/jar/basics/build.html
for more details.
As for code signing ... that's a rather involved topic. Here are a couple of links.
http://mindprod.com/signedapplets.html http://graphics.lcs.mit.edu/vrmlTracer/installCertificate.html http://www.suitable.com/CodeSigningCerts.shtml
You may want to consider living with the warning, but then I'm a bit of a lazy guy.
Sean
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trupti,
I hope you found the responses helpful.
Please be sure to register with a proper name. "Trupti" does not follow the conventions. See here for details: http://www.javaranch.com/name.jsp
If you do not register properly, your account will be disabled. I would hate to see that happen.
Thank you.
Stephanie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic