🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Ted Byers Tue, 23 Mar 2004 20:18
Two last problems
#1084
Author: Ted Byers
Date: Tue, 23 Mar 2004 20:18
33 lines
2098 bytes
I have this test program working, almost.

The image I load is visible both at design time and, when the applet is run
in the applet viewer, at run time.

But there are two problems.

1) The image still does not appear, and is replaced by a small red 'X', when
the html file is opened in a browser (MS' IE).

2) When running in the applet viewer, the viewer ignores the size
information I give for the applet window, and as a result, only the top left
corner of the image is visible, even after I resize the window.  After I
resize the window to a size well able to accomodate the image I'm using, I
just get grey empty space around the image of the corner of the real image
rather than the real image centred in the window.

So, it is working in that some or all of my image is visible when I run the
applet from the applet viewer.  It isn't quite working in that the applet
viewer gets the window size wrong and an internet browser doesn't display
the image.

The line JBuilder9 adds when I select an image to use is:

    jLabel1.setIcon(new
ImageIcon(HotSpotImageTest.class.getResource("sunset.jpg")));

Is this correct for an applet?
Will this work in a browser once I figure out how to make a jar file?

Thanks,

Ted
Re: Two last problems
#1086
Author: pnichols
Date: Tue, 23 Mar 2004 22:43
25 lines
2044 bytes
Ted Byers wrote:

>
> 
> Is this correct for an applet?
> Will this work in a browser once I figure out how to make a jar file?
> 
If you do not have the image in the jar file, how can you assure that the
image is on the correct class path for the applet?

In other words, remember that the image as run in applet viewer, is looking
at the image as residing in the same class folder as the applet when run
from the HTML page. When downloaded from a Web Server, the image MUST STILL
BE on the same classpath as your applet class that is using
getClass().getResource("imagename.gif"); 

Once you download an applet from a Web Server, the cache folder where the
applets are stored, is WHERE THE CLASSPATH IS. So it is no longer in the
same class path as it was in JB, it is now whereever your version of IE
places it. If the image is not in that same, folder, it will not work.

Once you place all of this into a jar file, the equation changes, since the
classpath becomes the .jar file. If the image is on the classes classpath
where your image jLabel is located, then it will display. Otherwise, it
will not.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads