🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.java
12 messages
12 total messages Started by Martin Schou Mon, 11 Feb 2002 14:00
[eng] Need help with an applet (110 line applet included)
#598
Author: Martin Schou
Date: Mon, 11 Feb 2002 14:00
149 lines
5151 bytes
First off let me apologize for the crossposting and for the english post to
a danish newsgroup.

Below is a stripped version of an applet, I've been trying to get to work
for the last week or so.
What it's supposed to do:

Get some images from the net (duh) and place them with pixel-precision.

I use the method
    private Image ReadImageFromURL( String image )
to return the apropriate image (we can't have inapropriate images in a
decent program), which basically just uses
    Applet.getImage(URL url, String name)
to return the image. It forms the URL from the variables
    String ImageHost, ImageDirectory

I can get this to work in AppletViewer, but I'll be a cross eyed monkey, if
it will work in a browser. This is rather unfortunate, as I need this to
work in a browser. I will gladly sacrifice my oldest child (at this point in
time) to anyone who can get this to work in a browser; I will up the ante
with my youngest child (at this point in time), if the same person can tell
me why my puny attempt doesn't work like it's supposed to.


/************************ start of applet ************************/
/******************* beware forced line breaks *******************/
import java.applet.Applet;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Label;

import java.io.InputStream;

import java.net.URL;

public class
Applet_That_Will_Not_Work_No_Matter_What_I_Try_Which_Is_Why_I_Need_Your_Help
extends Applet implements /*Helpless_Programmer, Annoying_Piece_Of_Shit*/
Runnable
  {
    Thread RunningThread;
    Image Buffer;
    Graphics GraphicsBuffer;

    String ImageHost = "http://";
    String ImageDirectory = "/img/";
    Image Background;

    public void init()
      {
        ImageHost +=  getCodeBase().getHost();
        setSize( 1013, 609 );
        Buffer = createImage(size().width,size().height);
        GraphicsBuffer = Buffer.getGraphics();
        initImages();
      }

    public void start()
      {
        if (RunningThread == null)
          {
            RunningThread = new Thread (this);
            RunningThread.start();
          }
      }

    public void stop()
      {
        if (RunningThread != null)
          {
            RunningThread.stop();
            RunningThread = null;
          }
      }

    public void run()
      {
        while(true)
          {
            drawImages();
            repaint();
            System.out.println("repaint()");
            Sleep( 5000 );
          }
      }

    private void Sleep( int time )
      {
        try
          {
            RunningThread.sleep( time );
          }
        catch( InterruptedException e )
          {
            e = null;
          }
      }

    public void update(Graphics g)
      {
        paint(g);
      }

    public void paint(Graphics g)
      {
        g.drawImage (Buffer,0,0, this);
      }

    private Image ReadImageFromURL( String image )
      {
        try
          {
            return getImage( new URL( ImageHost ), ImageDirectory + image );
          }
        catch( Exception e )
          {
            e.printStackTrace();
            e = null;
          }

        return null;
      }

    private void drawImage( Image ImageToManipulate, int x_coords, int
y_coords, int width, int height )
      {
        GraphicsBuffer.drawImage(ImageToManipulate, x_coords, y_coords,
width, height, null);
      }

    private void drawImages()
      {
        drawImage( Background,               0, 0, 1013, 609 );
      }

    private void initImages()
      {
        Background       = ReadImageFromURL( "ventilationsanlaeg.png" );
      }
  }
/************************* end of applet *************************/

And in case you're wondering, no - I don't have any children, which is why
I'm willing to sacrifice them only at this point in time.

Sincerely and frustrated
Martin Schou
Re: [eng] Need help with an applet (110 line applet included)
#599
Author: J N
Date: Mon, 11 Feb 2002 17:24
160 lines
5591 bytes
Martin Schou wrote:
> First off let me apologize for the crossposting and for the english post to
> a danish newsgroup.
> 
> Below is a stripped version of an applet, I've been trying to get to work
> for the last week or so.
> What it's supposed to do:
> 
> Get some images from the net (duh) and place them with pixel-precision.
> 
> I use the method
>     private Image ReadImageFromURL( String image )
> to return the apropriate image (we can't have inapropriate images in a
> decent program), which basically just uses
>     Applet.getImage(URL url, String name)
> to return the image. It forms the URL from the variables
>     String ImageHost, ImageDirectory
> 
> I can get this to work in AppletViewer, but I'll be a cross eyed monkey, if
> it will work in a browser. This is rather unfortunate, as I need this to
> work in a browser. I will gladly sacrifice my oldest child (at this point in
> time) to anyone who can get this to work in a browser; I will up the ante
> with my youngest child (at this point in time), if the same person can tell
> me why my puny attempt doesn't work like it's supposed to.
> 


What is the problem, except that "its doesn't work"?

Post a link that will run the applet.


> 
> /************************ start of applet ************************/
> /******************* beware forced line breaks *******************/
> import java.applet.Applet;
> 
> import java.awt.Graphics;
> import java.awt.Image;
> import java.awt.Label;
> 
> import java.io.InputStream;
> 
> import java.net.URL;
> 
> public class
> Applet_That_Will_Not_Work_No_Matter_What_I_Try_Which_Is_Why_I_Need_Your_Help
> extends Applet implements /*Helpless_Programmer, Annoying_Piece_Of_Shit*/
> Runnable
>   {
>     Thread RunningThread;
>     Image Buffer;
>     Graphics GraphicsBuffer;
> 
>     String ImageHost = "http://";
>     String ImageDirectory = "/img/";
>     Image Background;
> 
>     public void init()
>       {
>         ImageHost +=  getCodeBase().getHost();
>         setSize( 1013, 609 );
>         Buffer = createImage(size().width,size().height);
>         GraphicsBuffer = Buffer.getGraphics();
>         initImages();
>       }
> 
>     public void start()
>       {
>         if (RunningThread == null)
>           {
>             RunningThread = new Thread (this);
>             RunningThread.start();
>           }
>       }
> 
>     public void stop()
>       {
>         if (RunningThread != null)
>           {
>             RunningThread.stop();
>             RunningThread = null;
>           }
>       }
> 
>     public void run()
>       {
>         while(true)
>           {
>             drawImages();
>             repaint();
>             System.out.println("repaint()");
>             Sleep( 5000 );
>           }
>       }
> 
>     private void Sleep( int time )
>       {
>         try
>           {
>             RunningThread.sleep( time );
>           }
>         catch( InterruptedException e )
>           {
>             e = null;
>           }
>       }
> 
>     public void update(Graphics g)
>       {
>         paint(g);
>       }
> 
>     public void paint(Graphics g)
>       {
>         g.drawImage (Buffer,0,0, this);
>       }
> 
>     private Image ReadImageFromURL( String image )
>       {
>         try
>           {
>             return getImage( new URL( ImageHost ), ImageDirectory + image );
>           }
>         catch( Exception e )
>           {
>             e.printStackTrace();
>             e = null;
>           }
> 
>         return null;
>       }
> 
>     private void drawImage( Image ImageToManipulate, int x_coords, int
> y_coords, int width, int height )
>       {
>         GraphicsBuffer.drawImage(ImageToManipulate, x_coords, y_coords,
> width, height, null);
>       }
> 
>     private void drawImages()
>       {
>         drawImage( Background,               0, 0, 1013, 609 );
>       }
> 
>     private void initImages()
>       {
>         Background       = ReadImageFromURL( "ventilationsanlaeg.png" );
>       }
>   }
> /************************* end of applet *************************/
> 
> And in case you're wondering, no - I don't have any children, which is why
> I'm willing to sacrifice them only at this point in time.
> 
> Sincerely and frustrated
> Martin Schou
> 
> 
> 
Re: [eng] Need help with an applet (110 line applet included)
#600
Author: J N
Date: Mon, 11 Feb 2002 17:24
160 lines
5543 bytes
Martin Schou wrote:
> First off let me apologize for the crossposting and for the english post to
> a danish newsgroup.
> 
> Below is a stripped version of an applet, I've been trying to get to work
> for the last week or so.
> What it's supposed to do:
> 
> Get some images from the net (duh) and place them with pixel-precision.
> 
> I use the method
>     private Image ReadImageFromURL( String image )
> to return the apropriate image (we can't have inapropriate images in a
> decent program), which basically just uses
>     Applet.getImage(URL url, String name)
> to return the image. It forms the URL from the variables
>     String ImageHost, ImageDirectory
> 
> I can get this to work in AppletViewer, but I'll be a cross eyed monkey, if
> it will work in a browser. This is rather unfortunate, as I need this to
> work in a browser. I will gladly sacrifice my oldest child (at this point in
> time) to anyone who can get this to work in a browser; I will up the ante
> with my youngest child (at this point in time), if the same person can tell
> me why my puny attempt doesn't work like it's supposed to.
> 


What is the problem, except that "its doesn't work"?

Post a link that will run the applet


> 
> /************************ start of applet ************************/
> /******************* beware forced line breaks *******************/
> import java.applet.Applet;
> 
> import java.awt.Graphics;
> import java.awt.Image;
> import java.awt.Label;
> 
> import java.io.InputStream;
> 
> import java.net.URL;
> 
> public class
> Applet_That_Will_Not_Work_No_Matter_What_I_Try_Which_Is_Why_I_Need_Your_Help
> extends Applet implements /*Helpless_Programmer, Annoying_Piece_Of_Shit*/
> Runnable
>   {
>     Thread RunningThread;
>     Image Buffer;
>     Graphics GraphicsBuffer;
> 
>     String ImageHost = "http://";
>     String ImageDirectory = "/img/";
>     Image Background;
> 
>     public void init()
>       {
>         ImageHost +=  getCodeBase().getHost();
>         setSize( 1013, 609 );
>         Buffer = createImage(size().width,size().height);
>         GraphicsBuffer = Buffer.getGraphics();
>         initImages();
>       }
> 
>     public void start()
>       {
>         if (RunningThread == null)
>           {
>             RunningThread = new Thread (this);
>             RunningThread.start();
>           }
>       }
> 
>     public void stop()
>       {
>         if (RunningThread != null)
>           {
>             RunningThread.stop();
>             RunningThread = null;
>           }
>       }
> 
>     public void run()
>       {
>         while(true)
>           {
>             drawImages();
>             repaint();
>             System.out.println("repaint()");
>             Sleep( 5000 );
>           }
>       }
> 
>     private void Sleep( int time )
>       {
>         try
>           {
>             RunningThread.sleep( time );
>           }
>         catch( InterruptedException e )
>           {
>             e = null;
>           }
>       }
> 
>     public void update(Graphics g)
>       {
>         paint(g);
>       }
> 
>     public void paint(Graphics g)
>       {
>         g.drawImage (Buffer,0,0, this);
>       }
> 
>     private Image ReadImageFromURL( String image )
>       {
>         try
>           {
>             return getImage( new URL( ImageHost ), ImageDirectory + image );
>           }
>         catch( Exception e )
>           {
>             e.printStackTrace();
>             e = null;
>           }
> 
>         return null;
>       }
> 
>     private void drawImage( Image ImageToManipulate, int x_coords, int
> y_coords, int width, int height )
>       {
>         GraphicsBuffer.drawImage(ImageToManipulate, x_coords, y_coords,
> width, height, null);
>       }
> 
>     private void drawImages()
>       {
>         drawImage( Background,               0, 0, 1013, 609 );
>       }
> 
>     private void initImages()
>       {
>         Background       = ReadImageFromURL( "ventilationsanlaeg.png" );
>       }
>   }
> /************************* end of applet *************************/
> 
> And in case you're wondering, no - I don't have any children, which is why
> I'm willing to sacrifice them only at this point in time.
> 
> Sincerely and frustrated
> Martin Schou
> 
> 
> 
Re: [eng] Need help with an applet (110 line applet included)
#601
Author: Martin Schou
Date: Tue, 12 Feb 2002 09:59
20 lines
1985 bytes
> What is the problem, except that "its doesn't work"?

Browsers refuse to load the applet, it crashes with no error messages. I
tried sacrificing a chicken and a goat while dancing the sacred dance, but
neither Opera nor Internet Explorer wanted to tell me, why the applet
crashed.

It simply doesn't work.

> Post a link that will run the applet

That would be of little use, since I don't have access to a public server,
where I can place the applet. If, by some magic mumbo jumbo, you can gain
access to my private network without breaking various laws, the applet is
running at
http://192.168.1.39/Applet_That_Will_Not_Work_No_Matter_What_I_Try_Which_Is_
Why_I_Need_Your_Help.html
but I doubt that is of much use.

//Martin Schou
Re: [eng] Need help with an applet (110 line applet included)
#602
Author: Ingo Pakleppa
Date: Tue, 12 Feb 2002 10:18
35 lines
2348 bytes
You may already have tried that, but maybe it helps if you go to the
Control Panel, open the Java Plug-in settings, and enable Show Java
Console and Show Exception Dialog Box. IE would probably ignore this
and use its own JVM, but Opera should honor the settings you changed.
I think.

Ingo

On Tue, 12 Feb 2002 10:59:38 +0100, "Martin Schou"
<martin.schou@grue-hornstrup.dk> wrote:

>> What is the problem, except that "its doesn't work"?
>
>Browsers refuse to load the applet, it crashes with no error messages. I
>tried sacrificing a chicken and a goat while dancing the sacred dance, but
>neither Opera nor Internet Explorer wanted to tell me, why the applet
>crashed.
>
>It simply doesn't work.
>
>> Post a link that will run the applet
>
>That would be of little use, since I don't have access to a public server,
>where I can place the applet. If, by some magic mumbo jumbo, you can gain
>access to my private network without breaking various laws, the applet is
>running at
>http://192.168.1.39/Applet_That_Will_Not_Work_No_Matter_What_I_Try_Which_Is_
>Why_I_Need_Your_Help.html
>but I doubt that is of much use.
>
>//Martin Schou
>
>

Seeking a JAVA opportunity in San Diego
Re: [eng] Need help with an applet (110 line applet included)
#603
Author: Thorbjørn Ravn Andersen
Date: Tue, 12 Feb 2002 10:38
11 lines
1690 bytes
"Martin Schou" <martin.schou@grue-hornstrup.dk> writes:

> Browsers refuse to load the applet, it crashes with no error messages. I
> tried sacrificing a chicken and a goat while dancing the sacred dance, but
> neither Opera nor Internet Explorer wanted to tell me, why the applet
> crashed.

Try enabling Java Log in IE before accessing the HTML page
-- 
  Thorbj�rn Ravn Andersen
  http://unixsnedkeren.dk
Re: [eng] Need help with an applet (110 line applet included)
#604
Author: Martin Schou
Date: Tue, 12 Feb 2002 11:59
33 lines
2674 bytes
"Ingo Pakleppa" <ipakleppa@cox.net> wrote in message
news:3c68eb59.5384371@news.west.cox.net...
> You may already have tried that, but maybe it helps if you go to the
> Control Panel, open the Java Plug-in settings, and enable Show Java
> Console and Show Exception Dialog Box. IE would probably ignore this
> and use its own JVM, but Opera should honor the settings you changed.
> I think.

Hmm ... can't get Opera to show the console ... anyways, I got the applet
working in Opera.
javac -target 1.1 appletname.java
helped with that (thank you Lasse Westh-Nielsen)

Now I can't get it running in Internet Explorer. The Console in Explorer
says the following:

java.lang.ClassNotFoundException: java.security.AccessControlException
 at com/ms/vm/loader/URLClassLoader.loadClass
 at java/lang/ClassLoader.loadClassInternal
 at Empty_2.init
 at com/ms/applet/AppletPanel.securedCall0
 at com/ms/applet/AppletPanel.securedCall
 at com/ms/applet/AppletPanel.processSentEvent
 at com/ms/applet/AppletPanel.processSentEvent
 at com/ms/applet/AppletPanel.run
 at java/lang/Thread.run
I don't use java.security.AccessControlException, or anything from the
java.security package, so I guess it's something that is automatically
loaded - but not supported by Internet Explorer? Any ideas as to how to
solve that problem?

Martin Schou
Re: [eng] Need help with an applet (110 line applet included)
#605
Author: J N
Date: Tue, 12 Feb 2002 21:54
37 lines
2760 bytes
Martin Schou wrote:
> "Ingo Pakleppa" <ipakleppa@cox.net> wrote in message
> news:3c68eb59.5384371@news.west.cox.net...
> 
>>You may already have tried that, but maybe it helps if you go to the
>>Control Panel, open the Java Plug-in settings, and enable Show Java
>>Console and Show Exception Dialog Box. IE would probably ignore this
>>and use its own JVM, but Opera should honor the settings you changed.
>>I think.
>>
> 
> Hmm ... can't get Opera to show the console ... anyways, I got the applet
> working in Opera.
> javac -target 1.1 appletname.java
> helped with that (thank you Lasse Westh-Nielsen)
> 
> Now I can't get it running in Internet Explorer. The Console in Explorer
> says the following:
> 
> java.lang.ClassNotFoundException: java.security.AccessControlException
>  at com/ms/vm/loader/URLClassLoader.loadClass
>  at java/lang/ClassLoader.loadClassInternal
>  at Empty_2.init
>  at com/ms/applet/AppletPanel.securedCall0
>  at com/ms/applet/AppletPanel.securedCall
>  at com/ms/applet/AppletPanel.processSentEvent
>  at com/ms/applet/AppletPanel.processSentEvent
>  at com/ms/applet/AppletPanel.run
>  at java/lang/Thread.run
> I don't use java.security.AccessControlException, or anything from the
> java.security package, so I guess it's something that is automatically
> loaded - but not supported by Internet Explorer? Any ideas as to how to
> solve that problem?
> 


Find out where the applet stops. Insert println statements.
Re: [eng] Need help with an applet (110 line applet included)
#606
Author: Martin Schou
Date: Thu, 14 Feb 2002 08:38
9 lines
1800 bytes
> Find out where the applet stops. Insert println statements.

If I override the constructor and insert a
"System.out.println("constructor");", it prints out constructor and then
throws the exception. It never reaches init(), which has
"System.out.println("init()"); as the very first line, and I have no idea
what is called after the constructor.

//Martin Schou
Re: [eng] Need help with an applet (110 line applet included)
#607
Author: Ingo Pakleppa
Date: Thu, 14 Feb 2002 11:48
41 lines
2862 bytes
On Tue, 12 Feb 2002 12:59:31 +0100, "Martin Schou"
<martin.schou@grue-hornstrup.dk> wrote:

>
>"Ingo Pakleppa" <ipakleppa@cox.net> wrote in message
>news:3c68eb59.5384371@news.west.cox.net...
>> You may already have tried that, but maybe it helps if you go to the
>> Control Panel, open the Java Plug-in settings, and enable Show Java
>> Console and Show Exception Dialog Box. IE would probably ignore this
>> and use its own JVM, but Opera should honor the settings you changed.
>> I think.
>
>Hmm ... can't get Opera to show the console ... anyways, I got the applet
>working in Opera.
>javac -target 1.1 appletname.java
>helped with that (thank you Lasse Westh-Nielsen)
>
>Now I can't get it running in Internet Explorer. The Console in Explorer
>says the following:
>
>java.lang.ClassNotFoundException: java.security.AccessControlException
> at com/ms/vm/loader/URLClassLoader.loadClass
> at java/lang/ClassLoader.loadClassInternal
> at Empty_2.init
> at com/ms/applet/AppletPanel.securedCall0
> at com/ms/applet/AppletPanel.securedCall
> at com/ms/applet/AppletPanel.processSentEvent
> at com/ms/applet/AppletPanel.processSentEvent
> at com/ms/applet/AppletPanel.run
> at java/lang/Thread.run
>I don't use java.security.AccessControlException, or anything from the
>java.security package, so I guess it's something that is automatically
>loaded - but not supported by Internet Explorer? Any ideas as to how to
>solve that problem?
>
>Martin Schou

Do other applets work in IE? It looks to me as if the JVM installation
might be messed up.

Seeking a JAVA opportunity in San Diego
Re: [eng] Need help with an applet (110 line applet included)
#608
Author: Martin Schou
Date: Thu, 14 Feb 2002 12:08
10 lines
1906 bytes
> Do other applets work in IE? It looks to me as if the JVM installation
> might be messed up.

Well - depending on what Applet it is, it works more or less fine. IE can
run the applets at java.sun.com/somethingorother just fine, so I'm pretty
sure it's my applet, that isn't behaving like it should.

Of course, I haven't programmed any (and I do mean any) applets before, so
I'm probably just doing something like I always do in a regular java
program, that is a big no no in applets.
Re: [eng] Need help with an applet (110 line applet included)
#609
Author: Ingo Pakleppa
Date: Fri, 15 Feb 2002 07:32
29 lines
2701 bytes
On Thu, 14 Feb 2002 13:08:51 +0100, "Martin Schou"
<martin.schou@grue-hornstrup.dk> wrote:

>> Do other applets work in IE? It looks to me as if the JVM installation
>> might be messed up.
>
>Well - depending on what Applet it is, it works more or less fine. IE can
>run the applets at java.sun.com/somethingorother just fine, so I'm pretty
>sure it's my applet, that isn't behaving like it should.
>
>Of course, I haven't programmed any (and I do mean any) applets before, so
>I'm probably just doing something like I always do in a regular java
>program, that is a big no no in applets.

The reason I thought it might be a messed-up IE is twofold: first,
your stack dump said "ClassDefNotFoundException" for a standard Java
class, and second, this apparently happens while trying to throw a
security violation exception. Except that it happens while loading the
init() method, before any of your code is ever executed, so there
should not be a chance for a security violation.

Looking at your stack trace again, I notice something else: it appears
that the method that is called is the wrong init() - in the wrong
class or something like that. It says "Empty_2.init()" where I would
have expected whatever_your_applet_class_name_is.init(). Do you have
an explanation, maybe?

Ingo
Seeking a JAVA opportunity in San Diego
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