[ale] OT: Swing + Applets

Christopher Fowler cfowler at outpostsentinel.com
Thu Aug 28 14:25:20 EDT 2003


Thanks!.

The applet does use getParameter() and it uses what I believe is
getContext() to get the IP of the host.  I'll have to overide those
methods and store the parameters inside of the method.


On Thu, Aug 28, 2003 at 02:18:44PM -0400, Jason Day wrote:
> On Thu, Aug 28, 2003 at 12:39:50PM -0400, Christopher Fowler wrote:
> > Does anyone know if it is possible to run an applet in a 
> > Swing or AWT container?
> 
> You mean a way to make a hybrid applet/application, that can run as
> either?  The simplest way is of course to use appletviewer, but I'm
> guessing that's not what you want.
> 
> If you want a hybrid applet/application, you will need to add some code
> that does what the browser does.  Here is a main method that should get
> you started:
> 
> public static void main (String args[]) {
>     // set applet flag
>     // your class should define this variable as a static
>     inApplet = false;
> 
>     // Create the frame to hold the applet. This can be a
>     // Frame or JFrame
>     JFrame frame = new JFrame ("Applet Frame");
> 
>     // instantiate the applet
>     MyApplet applet = new MyApplet();
> 
>     // add the applet to the frame
>     frame.getContentPane().add (applet, BorderLayout.CENTER);
> 
>     // resize the frame and make it visible
>     frame.setSize (640, 480);
>     frame.setVisible (true);
> 
>     // run the methods the browser normally would
>     applet.init();
>     applet.start();
> }
> 
> Depending on what your applet does, this might be all you need to do.
> If, however, your applet calls getAppletContext(), getParameter(),
> getCodeBase(), or getDocumentBase(), then you will need to override
> these methods to do something sensible.  That's where the inApplet flag
> comes into play: if inApplet is true, you just call the super and you're
> done.  There may also be other methods, but I think those are the most
> important ones.
> 
> HTH,
> Jason
> -- 
> Jason Day                                       jasonday at
> http://jasonday.home.att.net                    worldnet dot att dot net
>  
> "Of course I'm paranoid, everyone is trying to kill me."
>     -- Weyoun-6, Star Trek: Deep Space 9
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list