The Artima Developer Community
Sponsored Link

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

3 replies on 1 page. Most recent reply: Aug 21, 2002 4:40 PM by Julio C. Fonseca C.

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 3 replies 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


Jay Kandy

Posts: 77
Nickname: jay
Registered: Mar, 2002

Re: applets-package-images-appletv iewer problem !!? Posted: Aug 21, 2002 6:54 AM
Reply to this message Reply
appletviewer file.html doesnt work? What do you type in to run with appletviewer?

Julio C. Fonseca C.

Posts: 18
Nickname: jfonseca
Registered: Mar, 2002

Re: applets-package-images-applet v iewer problem !!? Posted: Aug 21, 2002 4:40 PM
Reply to this message Reply
Hi Jay,

I type just in a normal way,

appletviewer myFile.html

and it works fine if the applet doesn't belongs to a package.

The problems comes when I put the applet in a package (the applet is the same one I posted), as a matter of fact the problem happens when I run the applet in the appletviewer.

It works fine, when I run it in the browser.

Hope it helps to make a better description of my problem.


Greetings,
Julio

Julio C. Fonseca C.

Posts: 18
Nickname: jfonseca
Registered: Mar, 2002

Re: applets-package-images-applet v iewer problem !!? Posted: Aug 21, 2002 4:40 PM
Reply to this message Reply

Flat View: This topic has 3 replies on 1 page
Topic: how can we call a jsp from a servlet? Previous Topic   Next Topic Topic: GridLayout used in program problem HELP!!

Sponsored Links



Google
  Web Artima.com   

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