The Artima Developer Community
Sponsored Link

Java Answers Forum
applets-package-images-appletviewer problem !!?

1 reply on 1 page. Most recent reply: Aug 30, 2002 2:24 AM by Sebastian Rose

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Julio C. Fonseca C.

Posts: 18
Nickname: jfonseca
Registered: Mar, 2002

applets-package-images-appletviewer problem !!? Posted: Aug 20, 2002 8:13 PM
Reply to this message Reply
Advertisement
I have a problem when I try to run an applet that loads an image and display it. The applet belongs to a package.

The real problem is when I try to run the applet in the APPLETVIEWER, and THERE ARE NO problems when I run it in the browser., at this time I'm realizing that this is a java restriction?

The code of course is pretty straightforward, but I include the source .java and .html files.

package Pruebas.MisApplets;

import java.applet.Applet;
import java.awt.*;
import java.net.*;


public class MiApplet extends Applet
{
Image miImagen;
URL base;

public void init ()
{
try
{
base = getCodeBase();
}catch(Exception e)
{
System.out.println("Hubo un problema");
}

//miImagen = getImage(base, "pelicano.jpg");

Toolkit toolkit = Toolkit.getDefaultToolkit();
miImagen = toolkit.getImage("pelicano.jpg");

}

public void paint (Graphics g)
{
g.drawImage(miImagen, 10, 10, this);

g.drawString("Hola, mundo", 50, 50);
}
}

the .html file,

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="580" height="380" align="baseline"

codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Ve rsion=1,2,2,0 <http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab>">
<PARAM NAME="code" VALUE="Pruebas.MisApplets.MiApplet.class">
<param name = "ARCHIVE" value = "MiPaquete.jar">
<param name = "codebase" value="C:\Documents and Settings\Chicas\My Documents\Julio\Pruebas\MisApplets\">

</object>

of course, I have created a .jar file called MiPaquete.jar that includes just the .class file

As I said it works fine in the browser, but what happens with the appletviewer, another point If I don't use packages then it works fine in both browser and appletviewer,

What's the forum opinion?

Julio


Sebastian Rose

Posts: 2
Nickname: bastianr
Registered: Aug, 2002

Re: applets-package-images-appletv iewer problem !!? Posted: Aug 30, 2002 2:24 AM
Reply to this message Reply
I Think this is a Security-problem. ToolKit.getDefaultToolKit....
Just use, what everyone els usesin applets:

<code>getImage(app.getDocumentBase(), imageName);</code>

Read the Documentation of java.applet.Applet.

Flat View: This topic has 1 reply on 1 page
Topic: Session Object & Server Crash Previous Topic   Next Topic Topic: Password Encryption

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use